You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在Kotlin中移除TextInputEditText的错误下划线?求对应属性名

移除TextInputEditText的拼写错误红色下划线

要移除文本存在拼写/语法错误时显示的红色下划线(覆盖基础下划线的那种),核心是关闭系统的拼写检查功能,对应的可选属性有两个:

可选属性1:直接禁用拼写建议与检查

在TextInputEditText标签中,修改android:inputType属性为:

android:inputType="textNoSuggestions"

该属性会同时关闭拼写建议和拼写检查,适合不需要任何拼写相关提示的场景。

可选属性2:单独禁用拼写检查

如果需要保留原有的android:inputType="text"设置(比如要保留其他输入特性),可以添加单独的拼写检查禁用属性:

android:spellCheckEnabled="false"

这个属性仅关闭拼写检查功能,不会影响输入类型的其他配置。

修改后的完整布局示例

<com.google.android.material.textfield.TextInputLayout
    android:id="@+id/inputLayout"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_marginHorizontal="20dp"
    android:layout_marginVertical="20dp"
    android:layout_marginTop="10dp"
    app:helperTextEnabled="true"
    app:helperTextTextColor="@color/red">

    <com.google.android.material.textfield.TextInputEditText
        android:id="@+id/newfolder"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:hint="Enter New Folder"
        android:imeOptions="actionNext"
        android:inputType="text"
        android:spellCheckEnabled="false" <!-- 新增禁用拼写检查属性 -->
        android:maxLength="32"
        android:scrollIndicators="bottom"
        android:scrollbars="horizontal"
        android:scrollHorizontally="true" />
</com.google.android.material.textfield.TextInputLayout>

注:这个红色下划线是Android系统拼写检查的默认提示,并非Material组件调用setError()触发的错误状态样式,因此通过关闭拼写检查即可移除。

内容的提问来源于stack exchange,提问作者jetberrocal

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.22 00:21:03