2013-08-21 34 views
2

我有我的應用程序的EditText,我希望它有兩條線,顯示輸入法按鈕,而不是輸入鍵和(在SMS的應用程序等)移動太長的文字下一行。現在我有這樣的事情:的EditText移動長文本到下一行

<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" /> 

它有兩個我提到的第一個屬性,但我不記得任何選項,讓我達到第三。

例如:如果我EditText一行有10個字符,我想顯示的文字 「ABC ABCD ABC ABCDEFGHIJK」 這樣的:

abc abcd 
abc abc... 

編輯: 看來問題出在android:inputType="textImeMultiLine"。當我把它改成android:inputType="textMultiLine"一切工作正常,但是...我有進入按鈕而不是IME按鈕,我想避免的。

+0

你可以在你到底想要什麼更清晰.. – Hariharan

+0

如果文本不能在一行中顯示(因爲文字太長),我想在第二行顯示其餘部分。 – Seblis

+0

'android:lines'可能是.. – CRUSADER

回答

0

嘗試this..Hope很有效!

<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" /> 
+0

原創和這個有什麼不同? – ArieDov

+0

缺少'android:inputType'也許? – kassim

0

在XML android:maxLines="2"添加此代替android:lines="2"

+0

我已經試過了,它不適合我。 – Seblis

0

加入這一行

安卓的inputType =「textMultiLine」