I have an EditText
in my app and I want it to have two lines, to show ime button instead of enter key and to move too long text to next line (like in sms apps). For now i have something like this:
<AutoCompleteTextView
android:id="@+id/name_field"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginLeft="10dp"
android:layout_weight="1"
android:background="@null"
android:freezesText="true"
android:hint="@string/some_hint"
android:imeOptions="actionNext"
android:maxLength="100"
android:nextFocusDown="@null"
android:lines="2"
android:ellipsize="end"
android:inputType="textImeMultiLine"
android:selectAllOnFocus="true"
android:textColor="@android:color/black"
android:textSize="16sp" />
It has two first properties I mentioned, but i can't recall any option that allows me to reach third.
For example: if one line in my EditText
has 10 chars, i want to display text "abc abcd abc abcdefghijk" like that:
abc abcd
abc abc...
EDIT:
It seems problem is in android:inputType="textImeMultiLine"
. When i changed it to android:inputType="textMultiLine"
all works fine, but... I have enter button instead of IME button, which i want to avoid.
None of these Methods worked for me. After Googling for about an hour, I found this piece of code:
Keep your EditText like this:
I don't remember where I got this code from so can't credit the author. I made the necessary changes according to my need.
Try this..Hope it will work!
add this in your xml
android:maxLines="2"
instead ofandroid:lines="2"
add this line
android:inputType="textMultiLine"