lopez.mikhael lopez.mikhael - 3 months ago 15
Android Question

How to disable 'contentDescription' warning on gradle with lintOptions?

I would like to disable this warning:


[Accessibility] Missing 'contentDescription' attribute on image


I know the solution
android:contentDescription:"@null"
. But I want to be able to do the entire project and not on each of my ImageView.

On documentation of tools android, they advocate to do it like this:

android {
lintOptions {
disable 'TypographyFractions','TypographyQuotes'
...
}
}


My question is what is the name of lint options for this warning "contentDescription attribute on image"?




Edit, My Solution:

Click onĀ Suppress with @SuppressLint (Java) or tools:ignore (XML)

preview

This button add this on your
<ImageView .. />
:

tools:ignore="ContentDescription"


So you just need to add this lintOptions on your
build.gradle
:

android {
lintOptions {
disable 'ContentDescription'
}
}

Answer

I think you can disable it in your gradle config as well. You can find a list of Lint issues here. If you check it the you can see that it contains the TypographyFractions and it contains also the ContentDescription. Please note that I didn't try them but I think it should work.

So in my opinion you should do it in the following way:

android {
    lintOptions {
        disable 'ContentDescription'
        ...
    }
}
Comments