我想禁用此警告:
[Accessibility] Missing 'contentDescription' attribute on image
我知道解决方案 android:contentDescription:"@null"
.但我希望能够完成整个项目,而不是在我的每个 ImageView 上。
关于 documentation of tools android ,他们提倡这样做:
android {
lintOptions {
disable 'TypographyFractions','TypographyQuotes'
...
}
}
我的问题是这个警告“contentDescription attribute on image”的 lint 选项的名称是什么?
编辑,我的解决方案:
点击Suppress with @SuppressLint (Java) or tools:ignore (XML)
此按钮将此添加到您的 <ImageView .. />
:
tools:ignore="ContentDescription"
所以你只需要在你的 build.gradle
上添加这个 lintOptions :
android {
lintOptions {
disable 'ContentDescription'
}
}
最佳答案
我认为您也可以在您的 gradle 配置中禁用它。
您可以找到 Lint 问题列表 here .如果您检查它,您可以看到它包含 TypographyFractions
并且还包含 ContentDescription
。请注意,我没有尝试过它们,但我认为它应该有效。
所以在我看来你应该按照以下方式来做:
android {
lintOptions {
disable 'ContentDescription'
...
}
}
关于android - 如何使用 lintOptions 在 gradle 上禁用 'contentDescription' 警告?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39169243/