Android Lint contentDescription warning Android Lint contentDescription warning android android

Android Lint contentDescription warning


Resolved this warning by setting attribute android:contentDescription for my ImageView

android:contentDescription="@string/desc"

Android Lint support in ADT 16 throws this warning to ensure that image widgets provide a contentDescription.

This defines text that briefly describes content of the view. This property is used primarily for accessibility. Since some views do not have textual representation this attribute can be used for providing such.

Non-textual widgets like ImageViews and ImageButtons should use the contentDescription attribute to specify a textual description of the widget such that screen readers and other accessibility tools can adequately describe the user interface.


Disabling Lint warnings will easily get you into trouble later on. You're better off just specifying contentDescription for all of your ImageViews. If you don't need a description, then just use:

android:contentDescription="@null"


Another option is to suppress the warning individually:

xmlns:tools="http://schemas.android.com/tools"  (usually inserted automatically)tools:ignore="contentDescription"

Example:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"    xmlns:tools="http://schemas.android.com/tools"    android:layout_width="match_parent"    android:layout_height="match_parent"     tools:ignore="contentDescription" >       <ImageView            android:layout_width="50dp"            android:layout_height="match_parent"            android:adjustViewBounds="true"            android:padding="5dp"            android:src="@drawable/icon" />