2015-04-07 78 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上

相关问题