I get an warning about [Accessibility]Missing contentDescription attribute on image in eclipse. This warning show at line 5 (declare ImageView
) in XML code below.
This not make any error when build and run my application. But I really want to know why i get this warning.
This is my XML file:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<ImageView
android:id="@+id/contact_entry_image"
android:src="@drawable/ic_launcher"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
<TextView
android:id="@+id/contact_entry_text"
android:text=""
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textSize="30sp"
/>
</LinearLayout>
Please help me regarding this and thanks for your reading.
Add
android:contentDescription="@string/description"
(static or dynamic) to your ImageView. Please do not ignore nor filter the message, because it is helpfull for people using alternative input methods because of their disability (Like TalkBack, Tecla Access Shield etc etc).This warning tries to improve accessibility of your application.
To disable missing content description warning in the whole project, you can add this to your application module build.gradle
Updated:
As pointed out in the comments, setting the description to null indicates that the image is purely decorative and is understood as that by screen readers like TalkBack.
Old answer, I no longer support this answer:
For all the people looking how to avoid the warning:
I don't think
android:contentDescription="@null"
is the best solution.I'm using
tools:ignore="ContentDescription"
that is what is meant to be.Make sure you include
xmlns:tools="http://schemas.android.com/tools"
in your root layout.If you don't care at all do this:
Although I would advise the accepted solutions, this is a hack :D
The warning is indeed annoying and in many (most!) cases no contentDescription is necessary for various decorative ImageViews. The most radical way to solve the problem is just to tell the Lint to ignore this check. In Eclipse, go to "Android/Lint Error Checking" in Preferences, find "contentDescription" (it is in the "Accessibility" group) and change "Severity:" to Ignore.
Follow this link for solution: Android Lint contentDescription warning
This link for explanation: Accessibility, It's Impact and Development Resources
This guide is for making your app accessible: Making Apps More Accessible