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

如何在Android Studio中针对特定资源文件禁用拼写检查?

Android strings.xml本地禁用Lint拼写检查的方法

单字符串元素级禁用

直接在<string>标签内添加tools:ignore="SpellCheckingInspection"属性即可,前提是XML文件已声明tools命名空间(项目默认通常已包含,若未声明需在根标签补充xmlns:tools="http://schemas.android.com/tools")。示例代码:

<string name="sol3" tools:ignore="SpellCheckingInspection">sol3</string>

整个资源文件级禁用

如果要禁用整个strings.xml文件的拼写检查,在根标签<resources>上添加tools:ignore="SpellCheckingInspection"属性即可:

<resources xmlns:tools="http://schemas.android.com/tools" tools:ignore="SpellCheckingInspection">
    <string name="sol3">sol3</string>
    <string name="abc123">abc123</string>
</resources>

补充说明

  • 这是Android Lint官方支持的本地禁用方式,无需额外维护独立资源文件或调整Scope设置。
  • 若项目未声明tools命名空间,必须先在根标签添加声明,否则禁用属性无法生效。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.23 12:48:34