11

Anybody have come across with this situation. I need to show minimum 4 lines for edittext and when minLines given itworks fine But when add inputType tag to it , Min Lines fails..

          <EditText
                android:id="@+id/my_review_review_text"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginBottom="5dp"
                android:inputType="textCapSentences|textAutoCorrect"
                android:background="@drawable/rect"
                android:gravity="top|left"
                android:hint="Add a review"
                android:maxLines="5"
                android:minLines="4"
                android:padding="10dp" />

Please correct me if am wrong and provide me a solution....

GvSharma
  • 2,632
  • 1
  • 24
  • 30

4 Answers4

30

You can use android:inputType="textCapSentences|textMultiLine|textAutoCorrect"

<EditText
        android:id="@+id/notes_box"
        android:inputType="textCapSentences|textMultiLine|textAutoCorrect"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_below="@+id/notes_title"
        android:layout_marginLeft="16dp"
        android:layout_marginRight="16dp"
        android:padding="9dp"
        android:lines="5"
        android:gravity="top|left"
        android:maxLength="500"
        android:textColor="@color/gray"/>
Piyush
  • 18,895
  • 5
  • 32
  • 63
Shailesh
  • 490
  • 5
  • 11
  • Have you used android:inputType="textCapSentences|textMultiLine|textAutoCorrect" – Shailesh Apr 23 '15 at 13:32
  • 2
    yes...textMultiline works... can you explain me why this fails "android:inputType="textCapSentences|textAutoCorrect"" – GvSharma Apr 23 '15 at 13:34
  • | is a pipe operator. It concats all the option you are providing. the "textCapSentences|textMultiLine|textAutoCorrect" means the flags textCapSentences and textMultiLine and textAutoCorrect are on for inputType – Shailesh Apr 23 '15 at 13:36
4

Try it..

      <EditText
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:inputType="textMultiLine"/>
Abhinav singh
  • 1,448
  • 1
  • 14
  • 31
0

This line has been removed

android:inputType = "textCapSentences|textAutoCorrect"
Abhinav singh
  • 1,448
  • 1
  • 14
  • 31
Mstack
  • 321
  • 1
  • 12
  • 1
    oh..i need that and by adding "textMultiline" for inPutType using pipe operator we can achieve that – GvSharma Apr 23 '15 at 13:42
0

You can achieve this by simply adding inputType as MultiLine along with other inputTypes

<EditText
            android:id="@+id/comment"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"            
            android:inputType="textMultiLine|textNoSuggestions"
            android:minLines="6"
            android:focusable="true"
            android:focusableInTouchMode="true"
            android:gravity="top"
            android:padding="5dp"
            android:textSize="20sp"
            />
andrei
  • 2,934
  • 2
  • 23
  • 36
Raghavendra B
  • 441
  • 3
  • 10