2015-04-07 80 views
-1

我正在定義如下的EditText。我希望Done按鈕出現在軟鍵盤上,但我改爲使用Return按鈕。完成按鈕不會出現在Android軟鍵盤上

<EditText 
     android:id="@+id/txtCommentContent" 
     android:layout_width="match_parent" 
     android:layout_height="160dp" 
     android:layout_margin="5dp" 
     android:background="@drawable/bg_edittext_gradient" 
     android:gravity="top|start" 
     android:hint="@string/strHintContentComment" 
     android:maxLines ="4" 
     android:imeOptions="actionDone" 
     android:padding="5dp" 
     android:textSize="15sp" 
     android:textColor="@color/black" 
     android:scrollHorizontally="false"/> 

任何人都可以指出我做錯了什麼?

+0

add'inputTy pe',然後再次檢查。 –

回答

3

你試過了嗎?

editText.setImeOptions(editText.getImeOptions()| EditorInfo.IME_ACTION_DONE); 

隨着

android:inputType="text" 
+0

我添加了它,它可以工作,但我失去了文本打包功能。我需要的是文本換行到下一行,而不是隨着'完成'按鈕滾動 – Noorul

+0

@Noorul你可以將其設置爲最後一個'Edittext' ... –

+0

但是,如果你有android:inputType = textMultiline你要去編寫一行額外的代碼: editText.setRawInputType(InputType.TYPE_CLASS_TEXT); – blackjack

1

您需要添加:

android:singleLine="true" 

完成按鈕將顯示,但你不能使用完成按鈕返回按鈕(下一行)同時在softkeyboard上

相關問題