Image Without `contentDescription`

エラー警告

contentDescriptionとは?

 状態:解決済  閲覧数:5,624  投稿日:2018-05-08  更新日:2018-05-08

アクセシビリティに関する属性


Android4.0で追加された
・「Explore-by-touch mode」が有効な場合、ユーザがタッチした要素のcontentDescriptionにセットされた説明文が読み上げられる

警告表示


Image Without `contentDescription`
Empty contentDescription attribute on image  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.  Note that elements in application screens that are purely decorative and do not provide any content or enable a user action should not have accessibility content descriptions. In this case, just suppress the lint warning with a tools:ignore="ContentDescription" attribute.  Note that for text fields, you should not set both the hint and the contentDescription attributes since the hint will never be shown. Just set the hint. See

警告内容


画像に対するテキスト情報がない

ポイント
・警告なので、これが原因でbuildに失敗することはない
※この警告が表示された状態でもbuild自体は成功する



実際に遭遇した例

 閲覧数:594 投稿日:2018-05-08 更新日:2018-05-08

警告表示


Image Without `contentDescription`

修正前


▼layout/activity_main.xml
<ImageView
   android:id="@+id/imageView3"
   android:layout_width="200dp"
   android:layout_height="200dp"
   android:scaleType="matrix"
   app:layout_constraintBottom_toBottomOf="parent"
   app:layout_constraintStart_toStartOf="parent"
   app:srcCompat="@drawable/lion" />


修正後(ハードコーディング)


android:contentDescription="ライオン"を追加
▼layout/activity_main.xm
<ImageView
   android:id="@+id/imageView3"
   android:layout_width="200dp"
   android:layout_height="200dp"
   android:contentDescription="ライオン"
   android:scaleType="matrix"
   app:layout_constraintBottom_toBottomOf="parent"
   app:layout_constraintStart_toStartOf="parent"
   app:srcCompat="@drawable/lion" />


修正後(推奨)


android:contentDescription="@string/img_txt_lion"を追加
▼layout/activity_main.xm
<ImageView
   android:id="@+id/imageView3"
   android:layout_width="200dp"
   android:layout_height="200dp"
   android:contentDescription="ライオン"
   android:scaleType="matrix"
   app:layout_constraintBottom_toBottomOf="parent"
   app:layout_constraintStart_toStartOf="parent"
   app:srcCompat="@drawable/lion" />


▼values/strings.xml
<resources>
   <string name="app_name">First2 20180504</string>
   <string name="first">はじめて</string>
   <string name="tap_here">ここをタップ!</string>
   <string name="img_txt_lion">ライオン</string>
</resources>



This text field does not specify an inputType or a hint



週間人気ページランキング / 5-9 → 5-15
順位 ページタイトル抜粋 アクセス数
1 Android FAQ 17
2 run build する際、選択画面が表示されない | Android Studio(IDE) 8
3 ログイン 6
4 この行に複数マーカーがあります | エラー(エラー) 5
5 エディターを開くことができません: 予期しない例外が起こりました。 | エラー(エラー) 4
6 Android Studio で、ソースコードが改行できない | Android Studio(IDE) 2
6 実際に遭遇した例 2
6 ゲストコメント一覧ページ 2
6 2.「DDMS」利用 2
6 public 型 ★★ はそれ独自のファイル内に定義されなければなりません | エラー 2
6 cd: can't cd to data/data/パッケージ名/databases | Android Debug Bridge (adb) 2
7 Error: Could not access the Package Manager. Is the system running? | 環境構築 1
7 please select Android SDK | Android Studio(IDE) 1
7 Android Studio の Designプレビュー で、ウィジェットを中央に配置 | Android Studio(IDE) 1
7 .apk does not exist on disk. | Android Studio(IDE) 1
7 values-ja/strings.xmlに記載した内容が反映されない | 多言語化(環境構築) 1
7 実際に遭遇した例 1
7 ○○は解決できないか、フィールドではありません | エラー(エラー) 1
7 「Android Studio 3.0.1」で、デザインプレビュー画面が表示されない。「waiting build for finish」が終わらない | Android Studio(IDE) 1
7 The specified Android SDK Build Tools version (23.0.2) is ignored | Android Studio(IDE) 1
2026/5/16 5:05 更新