Android Lint 컨텐츠 설명 경고 경고가 표시됩니다.

imageview에 대해 “[액세스 가능성] 이미지에 contentDescription 속성이 누락되었습니다”라는 경고가 표시됩니다. 안드로이드 린트를 사용하는 동안

그게 무슨 뜻이야?



답변

android:contentDescription내 ImageView의 속성 을 설정하여이 경고를 해결했습니다.

android:contentDescription="@string/desc"

ADT 16의 Android Lint 지원은 이미지 위젯이 contentDescription을 제공하도록하기 위해이 경고를 발생시킵니다.

뷰의 내용을 간략하게 설명하는 텍스트를 정의합니다. 이 속성은 주로 접근성을 위해 사용됩니다. 일부 뷰에는 텍스트 표현이 없으므로이 속성을 사용하여 해당 속성을 제공 할 수 있습니다.

ImageViews 및 ImageButtons와 같은 텍스트가 아닌 위젯은 contentDescription 속성을 사용하여 화면 판독기 및 기타 내게 필요한 옵션 도구가 사용자 인터페이스를 적절히 설명 할 수 있도록 위젯에 대한 텍스트 설명을 지정해야합니다.


답변

린트 경고를 비활성화하면 나중에 쉽게 문제를 일으킬 수 있습니다. 모든 ImageView에 contentDescription을 지정하는 것이 좋습니다. 설명이 필요하지 않으면 다음을 사용하십시오.

android:contentDescription="@null"


답변

다른 옵션은 경고를 개별적으로 억제하는 것입니다.

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

예:

<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" />


답변

contentDescription을 추가하는 것이 좋습니다.

android:contentDescription="@string/contentDescriptionXxxx"

하지만 현실적이되자. 대부분의 사람들은 접근성을 위해 문자 그대로를 유지하지 않습니다. 그러나 노력이 거의 들지 않으면 장애가있는 사람들을 돕기 위해 무언가를 구현할 수 있습니다.

<string name="contentDescriptionUseless">deco</string>
<string name="contentDescriptionAction">button de action</string>
<string name="contentDescriptionContent">image with data</string>
<string name="contentDescriptionUserContent">image from an other user</string>

.

시각 장애인이 알아야 할 가장 중요한 것은 “계속하려면 클릭해야하는 버튼은 어디에 있습니까?”입니다.

클릭 가능한 내용에는 contentDescriptionAction을 사용하십시오.

정보가있는 이미지에는 contentDescriptionContent를 사용하십시오 (graph, textAsImage, …)

모든 사용자 제공 컨텐츠에 contentDescriptionUserContent를 사용하십시오.

나머지는 모두 contentDescriptionUseless를 사용하십시오.


답변

경고 일 뿐이므로 억제 할 수 있습니다. XML의 그래픽 레이아웃으로 이동하여 다음을 수행하십시오.

  1. 오른쪽 상단의 빨간 버튼을 클릭하십시오

    여기에 이미지 설명을 입력하십시오

  2. “문제 유형 비활성화”를 선택하십시오 (예 🙂

    여기에 이미지 설명을 입력하십시오


답변

이 특정 ImageView에 액세스 가능성이 필요하지 않기 때문에이 경고를 우아하게 표시하지 않으려는 경우 특수 속성을 사용할 수 있습니다.

android:importantForAccessibility="no"


답변

Gradle파일 (모듈 앱)로 이동하여 코드 블록 아래에 추가하십시오.

android {
    ...
    lintOptions {
        disable 'ContentDescription'
    }
    ...
}

더 이상 경고가 없습니다! 행복한 코딩