如何使用lintOptions禁用gradle上的"contentDescription"警告?

lop*_*ael 7 android lint android-lint

我想禁用此警告:

[辅助功能]图像上缺少'contentDescription'属性

我知道解决方案android:contentDescription:"@null".但我希望能够完成整个项目而不是每个ImageView.

关于android工具的文档,他们主张这样做:

android {
    lintOptions {
        disable 'TypographyFractions','TypographyQuotes'
        ...
    }
}
Run Code Online (Sandbox Code Playgroud)

我的问题是这个警告"图像上的contentDescription属性"的lint选项名称是什么?


编辑,我的解决方案:

单击  Suppress with @SuppressLint(Java)或工具:ignore(XML)

这个按钮在你的上面添加<ImageView .. />:

tools:ignore="ContentDescription"
Run Code Online (Sandbox Code Playgroud)

所以你只需要在你的上面添加这个lintOptions build.gradle:

android {
    lintOptions {
        disable 'ContentDescription'
    }
}
Run Code Online (Sandbox Code Playgroud)

Ble*_*ehi 13

我想你也可以在你的gradle配置中禁用它.您可以在此处找到Lint问题列表.如果你检查它,你可以看到它包含它TypographyFractions,它也包含ContentDescription.请注意,我没有尝试过,但我认为它应该可行.

所以在我看来你应该用以下方式做到:

android {
    lintOptions {
        disable 'ContentDescription'
        ...
    }
}
Run Code Online (Sandbox Code Playgroud)