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
to your image. Make sure you have
xmlns:tools="http://schemas.android.com/tools" .
in your root layout.Going forward, for graphical elements that are purely decorative, the best solution is to use:
This makes sense if your min SDK version is at least 16, since devices running lower versions will ignore this attribute.
If you're stuck supporting older versions, you should use (like others pointed out already):
Source: https://developer.android.com/guide/topics/ui/accessibility/apps#label-elements