7

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'
    }
}
lopez.mikhael
  • 9,943
  • 19
  • 67
  • 110

2 Answers2

14

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'
        ...
    }
}
Blehi
  • 1,990
  • 1
  • 18
  • 20
  • 1
    Perfect solution! I don't want to do it for ALL projects, just certain ones that I know won't ever be used by blind people (like my own test apps). This does the trick without having to put a line in every layout file. – SMBiggs Mar 06 '18 at 04:32
1

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.

sumandas
  • 555
  • 7
  • 20