以编程方式禁用Gboard上的自动建议

Sui*_*eux 8 android gboard

我正在尝试以编程方式禁用setInputType()使用的建议InputType TYPE_TEXT_FLAG_NO_SUGGESTIONS.

虽然这适用于大多数键盘,但在使用"Gboard"键盘时这不起作用; 即使使用此输入类型,也会始终显示建议.问题是用户可以选择是否想要输入字段的建议,而不管EditText指定的输入类型.

如何抑制所有键盘的建议,包括Gboard?

Sui*_*eux 5

我找到了一个解决方案:

view.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD | InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS);
Run Code Online (Sandbox Code Playgroud)

但是,您可以看到带有建议和不带建议的 Input 之间的字体差异。

  • 删除 `InputType.TYPE_CLASS_TEXT` 为我解决了字体问题 (2认同)

PRA*_*WAJ -2

<EditText
                android:id="@+id/inputISD_Code"
                android:layout_width="0dip"
                android:layout_height="match_parent"
                android:layout_marginLeft="@dimen/dimen20"
                android:layout_weight="20"
                android:background="@null"
                android:fontFamily="sans-serif-light"
                android:hint="@string/code"
                android:inputType="text|textNoSuggestions"
                android:maxLength="10"
                android:textColor="@color/black"
                android:textCursorDrawable="@null"
                android:textSize="18dp" />
Run Code Online (Sandbox Code Playgroud)