android - 如何删除软键盘上的多余空格

标签 android margin android-softkeyboard

我想知道如何删除软键盘的top 空格/边距。


为了更清晰的图片,请查看以下屏幕截图:

有空格和无空格:

enter image description here enter image description here

最佳答案

您看到的“间距”是自动完成建议区域。如果您将输入类型设置为像 text 这样简单的类型,那么您将从键盘获得建议。添加textNoSuggestions到您的 inputType 字段将删除建议区域。

例如:

<EditText android:id="@+id/username_field"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:inputType="textNoSuggestions"
    android:hint="@string/username" />

或者,如果您已经在使用类似 textCapWords 的东西,您可以像这样组合它们:

<EditText android:id="@+id/username_field"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:inputType="textCapWords|textNoSuggestions"
    android:hint="@string/username" />

此外,不确定您是否正在使用它,但请注意,您需要在密码字段中使用 inputType="password"

关于android - 如何删除软键盘上的多余空格,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16432230/

相关文章:

java - Android强制停止回调应用程序?

java - Firebase "Parcelable encountered IOException writing serializable object"对象包含 DocumentReference 的 ArrayList

css - 我如何判断哪种样式覆盖了另一种样式?

android - 如何在 android 中以编程方式启动带有数字 0 到 9 和 + 的软电话类型键盘?

android - 如何在用户单击 webview android 中的文本框时隐藏键盘

android - 如何在 searchView 中收听键盘搜索按钮

android - 存在的 AVD 不会在 "Target Tab"中列出

android - Android/iOS 上的蓝牙游戏

android - 以编程方式在 ListView 中设置 TextView 的边距/填充

html - css 应用代码中不存在的边距