如何在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
相关产品推荐
相关产品推荐

