Android 辅助功能 图像上缺少 contentDescription 属性如何删除此警告?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/11304847/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Accessibility Missing contentDescription attribute on image how to remove this warning?
提问by Salman Amjad
Accessibility] Missing contentDescription attribute on image
辅助功能] 图像上缺少 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" />
回答by Samir Mangroliya
In Eclipse
在日食中
Window->prefrences->Android->Lint Error Checking->Issues-> Accessibility->Content Decription->Severty select Ignore.
Window->prefrences->Android->Lint Error Checking->Issues-> Accessibility->Content Decrition->Severty 选择忽略。
OR
或者
add android:contentDescription
in ImageView.
android:contentDescription
在 ImageView 中添加。
回答by Vipul Shah
Lint support in ADT 16 and above throws this warning
ADT 16 及更高版本中的 Lint 支持会引发此警告
Now question is why this is needed.
现在的问题是为什么需要这样做。
Consider scenario where you have designed application which have ImageView with some image.The image carries message what it does.But there may be a blind person who can not see.So in that case if you have used contentDescription attribute then Text-To-Speech functionality will read the value so even blind person will come to for what purpose image is placed there even though he can't see it.
考虑一下您设计的应用程序的场景,其中包含带有一些图像的 ImageView。图像携带消息它的作用。但可能有一个看不见的盲人。所以在这种情况下,如果您使用了 contentDescription 属性,那么 Text-To-Speech功能将读取值,因此即使是盲人,即使他看不到图像,也会将图像放置在那里的目的。
contentDescription
defines text that briefly describes 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.
contentDescription
定义简要描述视图内容的文本。此属性主要用于可访问性。由于某些视图没有文本表示,因此该属性可用于提供此类表示。
Widgets like ImageViews and ImageButtons should use the contentDescription attribute to specify a textual description of the widget such that screen readers Text-To-Speech and other accessibility tools can adequately describe the user interface.
像 ImageViews 和 ImageButtons 这样的小部件应该使用 contentDescription 属性来指定小部件的文本描述,这样屏幕阅读器 Text-To-Speech 和其他辅助工具可以充分描述用户界面。
回答by ρяσ?ρ?я K
try by adding android:contentDescription
for ImageView
尝试通过添加android:contentDescription
ImageView
<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" />
for more info see
欲了解更多信息,请参阅
http://android-developers.blogspot.in/2012/04/accessibility-are-you-serving-all-your.html
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
http://developer.android.com/guide/topics/ui/accessibility/apps.html#test
回答by Yunus Se?gin
Type in ImageView
输入图像视图
android:contentDescription="TODO"
回答by Cho Hee
Just add this:
只需添加这个:
android:contentDescription="@string/description"
then go to yours Strings.xmland add this:
然后转到您的Strings.xml并添加以下内容:
<string name="description"> YOUR_DESCRIPTION_HERE </string>