Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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)

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'
    }
}
like image 764
lopez.mikhael Avatar asked Aug 26 '16 14:08

lopez.mikhael


2 Answers

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'
        ...
    }
}
like image 100
Blehi Avatar answered Oct 12 '22 10:10

Blehi


If not mistaken, you can disable them using Android Studio Preferences settings as follows:

Windows -> Preferences -> Inspection -> Uncheck "Image Without Content Description"

Try this tutorial to see how he has forced it to be converted to error. May be altering things here would fix it for you.

like image 24
sumandas Avatar answered Oct 12 '22 10:10

sumandas