对于imageview,我收到“图像上缺少contentDescription属性的辅助功能”的警告。在使用android lint时
那是什么意思?
发布于 2011-12-14 20:40:48
通过为我的ImageView设置属性android:contentDescription
解决了此警告
android:contentDescription="@string/desc"
Android Lint在ADT16中的支持抛出此警告,以确保图像小部件提供contentDescription。
这定义了简要描述视图内容的文本。此属性主要用于辅助功能。因为有些视图没有文本表示,所以这个属性可以用来提供文本表示。
像ImageViews和ImageButtons这样的非文本小部件应该使用contentDescription属性来指定小部件的文本描述,以便屏幕阅读器和其他辅助工具能够充分描述用户界面。
发布于 2013-07-12 05:12:07
禁用Lint警告很容易在以后给您带来麻烦。最好只为所有ImageViews指定contentDescription。如果您不需要描述,那么只需使用:
android:contentDescription="@null"
发布于 2013-05-19 07:26:44
另一种选择是逐个禁止显示警告:
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" />
https://stackoverflow.com/questions/8500544
复制相似问题