I gave an empty string. Lint still complains.
<ImageView style="@style/DetailFieldSeparator"/>
<style name="DetailFieldSeparator">
<item name="android:src">@android:drawable/divider_horizontal_textfield</item>
<item name="android:layout_width">match_parent</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:scaleType">fitXY</item>
<item name="android:paddingTop">5dp</item>
<item name="android:paddingBottom">5dp</item>
</style>
To mark an image as decorative, all that is required is that you supply an empty ALT attribute. To do this, simply provide ALT text of “” to indicate an empty ALT attribute. This will signal a screen reader to skip over the image, taking it out of the reading flow.
Just because an image doesn't need alt text written, it does not mean you can publish the image and do nothing else. You still need to mark the image as "decorative" so screen readers know to skip the image when reading out page content.
The Web Content Accessibility Guidelines 2.0 defines purely decorative images as: serving only an aesthetic purpose, providing no information, and having no functionality.
You can do this by adding the contentDescription attribute to your XML layout. It can also be done programmatically by calling the setContentDescription method in your Java file. Either method provides TalkBack with all the necessary information to describe the ImageView to users.
You can set the content description of a purely decorative image to "@null" to avoid Lint warnings and let the screen reader know to skip that image.
<ImageView
style="@style/DetailFieldSeparator"
android:contentDescription="@null" />
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With