Reputation: 119
I need my EditText component to move the text to the next line when it reaches the end of the row.
And does anyone know how to prevent EditText from expanding vertically when it's filled with text? Instead EditText should scroll vertically. Is there a way to make it without fixing the size of EditText?
I searched the Web for relevant information but haven't found the answers.
Upvotes: 8
Views: 10023
Reputation: 9442
Just use the following changes in your code.
in xml:
<EditText
android:id="@+id/editText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="top|start"
android:lines="5"
android:minLines="5"
android:maxLines="6"
android:singleLine="true" />
or programmatically
editText.apply {
gravity = Gravity.TOP or Gravity.START
setLines(5)
minLines = 5
maxLines = 6
isSingleLine = false
}
I hope this will work.
Upvotes: 0
Reputation: 7131
<EditText
android:id="@+id/DwEdit"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="9"
android:ems="10"
android:gravity="top"
android:imeOptions="flagNoExtractUi"
android:minLines="10"
android:scrollHorizontally="false"
android:scrollbarAlwaysDrawVerticalTrack="true"
android:scrollbarStyle="insideInset"
android:scrollbars="vertical"
android:overScrollMode="always"
android:inputType="textCapSentences">
</EditText>
Upvotes: 2
Reputation: 3552
Put this in XML:
Use maxHeight for EditText expand vertically problem and android:inputType="textMultiLine" for shifting text to next line.
<EditText
android:id="@+id/edit_text"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:maxHeight="140dp"
android:scrollbars="vertical"
android:inputType="textMultiLine"
>
</EditText>
Upvotes: 17