score:287

Accepted answer

follow this link for solution: 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 the 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.

this link for explanation: accessibility, it's impact and development resources

many android users have disabilities that require them to interact with their android devices in different ways. these include users who have visual, physical or age-related disabilities that prevent them from fully seeing or using a touchscreen.

android provides accessibility features and services for helping these users navigate their devices more easily, including text-to-speech, haptic feedback, trackball and d-pad navigation that augments their experience. android application developers can take advantage of these services to make their applications more accessible and also build their own accessibility services.

this guide is for making your app accessible: making apps more accessible

making sure your application is accessible to all users is relatively easy, particularly when you use framework-provided user interface components. if you only use these standard components for your application, there are just a few steps required to ensure your application is accessible:

  1. label your imagebutton, imageview, edittext, checkbox and other user interface controls using the android:contentdescription attribute.

  2. make all of your user interface elements accessible with a directional controller, such as a trackball or d-pad.

  3. test your application by turning on accessibility services like talkback and explore by touch, and try using your application using only directional controls.

score:0

also add this line in xml

android:contentdescription="@null"

activity_main.xml

<?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"
        android:contentdescription="@null"
        />
    <textview
        android:id="@+id/contact_entry_text"
        android:text=""
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:textsize="30sp"
        />

</linearlayout>

score:3

it is giving you the warning because the image description is not defined.

we can resolve this warning by adding this code below in strings.xml and activity_main.xml

add this line below in strings.xml

<string name="imgdescription">background picture</string>
you image will be like that:
<imageview
        android:id="@+id/imageview2"
        android:lay`enter code hereout_width="0dp"
        android:layout_height="wrap_content"
        android:contentdescription="@string/imgdescription"
        app:layout_editor_absolutex="0dp"
        app:layout_editor_absolutey="0dp"
        app:srccompat="@drawable/background1"
        tools:layout_editor_absolutex="0dp"
        tools:layout_editor_absolutey="0dp" />

also add this line in activity_main.xml

android:contentdescription="@string/imgdescription"

strings.xml

<resources>
    <string name="app_name">saini_browser</string>
    <string name="sainibrowser">textview2</string>
    <string name="imgdescription">background picture</string>
</resources>

score:9

if you don't care at all do this:

    android:contentdescription="@null"

although i would advise the accepted solutions, this is a hack :d

score:9

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

android {

    ...

    lintoptions {
        disable 'contentdescription'
    }
}

score:10

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.

score:12

add

tools:ignore="contentdescription"

to your image. make sure you have xmlns:tools="http://schemas.android.com/tools" . in your root layout.

score:15

going forward, for graphical elements that are purely decorative, the best solution is to use:

android:importantforaccessibility="no"

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):

android:contentdescription="@null"

source: https://developer.android.com/guide/topics/ui/accessibility/apps#label-elements

score:41

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.

score:70

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).


Related Query

More Query from same tag