mpk*_*uth 7 android android-lint
在整个项目中,我有一些"UnusedAttribute"的催眠警告.
elevation仅用于API级别21和更高级别(当前最小值为16)breakStrategy仅用于API级别23及更高级别(当前最小值为16)hyphenationFrequency仅用于API级别23及更高级别(当前最小值为16)letterSpacing仅用于API级别21和更高级别(当前最小值为16)我知道我可以禁止所有属性的警告.
tools:ignore="UnusedAttribute"
Run Code Online (Sandbox Code Playgroud)
要么
lintOptions {
disable 'UnusedAttribute'
}
Run Code Online (Sandbox Code Playgroud)
但是,我只想抑制特定属性的警告.我试图做以下事情但没有成功.
tools:ignore="UnusedAttribute:elevation"
Run Code Online (Sandbox Code Playgroud)
要么
lintOptions {
disable 'UnusedAttribute:elevation'
}
Run Code Online (Sandbox Code Playgroud)
为此,您可以通过配置lint lint.xml并使用regexp 来了解详细信息。让我们一步一步走。
首先,指定您将使用文件配置。这样的东西在你的build.gradle
lintOptions {
lintConfig file("../config/lint/lint.xml")
}
Run Code Online (Sandbox Code Playgroud)
在您的情况下,路径将有所不同。
其次,使用regexp排除特定属性。这是例子lint.xml
<?xml version="1.0" encoding="UTF-8"?>
<lint>
<issue id="UnusedAttribute">
<ignore regexp="elevation"/>
<ignore regexp="breakStrategy"/>
</issue>
</lint>
Run Code Online (Sandbox Code Playgroud)
另一种方法是tools:targetApi="n"为每种用法添加。其中“ n”是属性首次出现的版本。
| 归档时间: |
|
| 查看次数: |
2203 次 |
| 最近记录: |