问题描述
我的应用程序中有一个EditText
,我希望它有两行,显示ime按钮而不是Enter键,并且将太长的文本移动到下一行(例如在sms应用程序中).现在我有这样的东西:
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.
例如:如果我的EditText
中的一行有10个字符,我想显示这样的文本"abc abcd abc abcdefghijk":
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...
似乎问题出在android:inputType="textImeMultiLine"
中.当我将其更改为android:inputType="textMultiLine"
时,一切正常,但是...我想避免输入输入按钮而不是IME按钮.
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.
推荐答案
尝试一下.希望它能起作用!
Try this..Hope it will work!
<AutoCompleteTextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginLeft="10dp"
android:background="@null"
android:freezesText="true"
android:imeOptions="actionNext"
android:maxLength="100"
android:nextFocusDown="@null"
android:lines="2"
android:ellipsize="end"
android:selectAllOnFocus="true"
android:textColor="@android:color/black"
android:textSize="16sp" />
这篇关于EditText将长文本移到下一行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!