【问题标题】:Accessibility Missing contentDescription attribute on image how to remove this warning?可访问性图像上缺少 contentDescription 属性如何删除此警告?
【发布时间】:2012-07-03 05:14:03
【问题描述】:

辅助功能] 图片上缺少 contentDescription 属性

 <ImageView
            android:id="@+id/imageView1"
            android:layout_width="34dp"
            android:layout_height="61dp"
            android:layout_marginLeft="11dp"
            android:layout_marginRight="0dp"
            android:layout_marginTop="11dp"
            android:background="#ff3333"
            android:src="@drawable/arrows" />

【问题讨论】:

标签: android


【解决方案1】:

在 Eclipse 中

Window->prefrences->Android->Lint 错误检查->Issues-> 辅助功能->内容描述->严重选择忽略。

在 ImageView 中添加android:contentDescription

【讨论】:

  • by ignorng descriptption nw im getng ths warning 可能的过度绘制:根元素绘制背景 @drawable/temperature 的主题也绘制背景(推断的主题是 @android:style/Theme)... on xml 小部件... android:background="@drawable/temperature">
【解决方案2】:

ADT 16 及更高版本中的 Lint 支持会引发此警告

现在的问题是为什么需要这样做。

考虑您设计的应用程序具有 图像视图与 一些图像。图像传达了它的作用。但可能有一个盲人 谁看不到。所以在这种情况下,如果您使用了 contentDescription 属性 然后文本到语音功能将读取该值,因此即使是盲人也会 即使他看不到它,图像也被放置在那里。

contentDescription 定义简要描述视图内容的文本。此属性主要用于可访问性。由于某些视图没有文本表示,因此此属性可用于提供此类。

像 ImageViews 和 ImageButtons 这样的小部件应该使用 contentDescription 属性来指定小部件的文本描述,以便屏幕阅读器 Text-To-Speech 和其他辅助工具可以充分描述用户界面。

【讨论】:

  • by ignorng descriptption nw im getng ths warning 可能的过度绘制:根元素绘制背景 @drawable/temperature 的主题也绘制背景(推断的主题是 @android:style/Theme)... on xml 小部件... android:background="@drawable/temperature">
【解决方案3】:

尝试为 ImageView 添加android:contentDescription

<ImageView
            android:id="@+id/imageView1"
            android:layout_width="34dp"
            android:layout_height="61dp"
            android:layout_marginLeft="11dp"
            android:layout_marginRight="0dp"
            android:contentDescription="@string/desc"
            android:layout_marginTop="11dp"
            android:background="#ff3333"
            android:src="@drawable/arrows" />

更多信息见

http://android-developers.blogspot.in/2012/04/accessibility-are-you-serving-all-your.html

http://developer.android.com/guide/topics/ui/accessibility/apps.html#test

Android Lint contentDescription warning

【讨论】:

  • by ignorng descriptption nw im getng ths warning 可能的过度绘制:根元素绘制背景 @drawable/temperature 的主题也绘制背景(推断的主题是 @android:style/Theme)... on xml 小部件... android:background="@drawable/temperature">
【解决方案4】:

输入 ImageView

android:contentDescription="TODO"

【讨论】:

    【解决方案5】:

    只需添加:

    android:contentDescription="@string/description"
    

    然后转到你的 Strings.xml 并添加:

    <string name="description"> YOUR_DESCRIPTION_HERE </string>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-04-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-11-24
      • 2021-10-25
      • 1970-01-01
      • 2021-11-05
      相关资源
      最近更新 更多