Image Without `contentDescription`

エラー警告

contentDescriptionとは?

 状態:解決済  閲覧数:5,594  投稿日: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自体は成功する



実際に遭遇した例

 閲覧数:585 投稿日: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



週間人気ページランキング / 3-27 → 4-2
順位 ページタイトル抜粋 アクセス数
1 Android FAQ 11
2 ログイン 10
2 この行に複数マーカーがあります | エラー(エラー) 10
3 プラグイン "org.eclipse.ui.workbench" からのコードの起動で問題が発生しました | エラー(エラー) 8
4 ○○は解決できないか、フィールドではありません | エラー(エラー) 7
5 public 型 ★★ はそれ独自のファイル内に定義されなければなりません | エラー 6
6 エディターを開くことができません: 予期しない例外が起こりました。 | エラー(エラー) 4
7 「SQLite Database 」へ保存したデータを確認したい | SQLite 3
7 R.java was modified manually! Reverting to generated version! | エラー(エラー) 3
7 Android requires compiler compliance level 5.0 or 6.0. Found '1.7' instead. Please use Android Tools > Fix Project Properties | エラー(エラー) 3
8 Unexpected error while launching logcat | エラー(エラー) 2
8 アプリケーション起動時に表示されるアクティビティを変更 | 仕組み 2
8 Project build error: Non-resolvable parent POM: Failure to find | エラー 2
8 新規プロジェクトを作成する方法 | プロジェクト(環境構築) 2
8 emulator: エラー: Unable to load VM from snapshot. The snapshot has been saved for a different hardware configuration. | エラー(エラー) 2
8 .apk does not exist on disk. | Android Studio(IDE) 2
8 インポートされた ★★ は見つかりません | エラー 2
8 /gralloc_goldfish﹕ Emulator without GPU emulation detected. | エラー(エラー) 2
8 Emulator without GPU emulation detected | 環境構築 2
8 Failed to allocate memory: 8 | エラー(エラー) 2
2026/4/3 5:05 更新