以编程方式隐藏/禁用Android软键盘上的表情符号

时间:2014-05-09 09:08:06

标签: android android-edittext android-softkeyboard

是否可以隐藏特定的键盘按钮?我有一个EditText,在某些设备上,它的键盘有笑脸,而在其他设备上则丢失了。我想在所有设备上隐藏它。

以下是我EditText的XML:

android:id="@+id/text_editor"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignWithParentIfMissing="true"
android:layout_centerVertical="true"
android:layout_toLeftOf="@+id/send_side"
android:hint="Enter your text"
android:imeOptions="actionSend|flagNoEnterAction"
android:inputType="textLongMessage|textAutoCorrect|textCapSentences|textMultiLine"
android:maxLength="1000"
android:maxLines="3"
android:nextFocusRight="@+id/send_button"
android:padding="12dp"
android:textSize="13sp"

我不得不说我是Android新手,如果不可能,我想知道原因。

感谢您的帮助。

4 个答案:

答案 0 :(得分:13)

我真的不明白为什么这个问题被贬低了。这是一个有效的问题。

我找到了here

您需要从textLongMessage删除inputType选项。

你仍然会有": - )"大多数键盘上的按钮,但不是表情符号。

答案 1 :(得分:6)

(为了完整起见)

此解决方案适用于需要在软键盘上没有笑脸的情况下进行textview的人。 @ Adrian的解决方案,使用电子邮件地址类型,有效,但它会显示不必要的' @'和' .com'键盘上的按钮。我尝试了几种InputType和最佳解决方案的组合恕我直言:

mTextView.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD);

原装键盘: enter image description here

结果键盘: enter image description here

答案 2 :(得分:0)

这适用于Android 4.4.2

android:inputType="textEmailAddress|textMultiLine"

答案 3 :(得分:0)

我尝试了@Adrian的解决方案,但是它具有“ @”和“ .com”键。我只需要一个可以使用用户名的字段。通过结合textVisiblePassword和textNoSuggestions获得了解决方案。 android:inputType="textVisiblePassword|textNoSuggestions

相关问题