在Android XML中的图像缺少contentDescription属性

3

为什么在Android的ImageView中我会收到此警告?

    <ImageView
        android:id="@+id/user_image"
        android:layout_width="30dip"
        android:layout_height="30dip" />

3
可能是https://dev59.com/aWkw5IYBdhLWcg3wqMY1的重复问题。 - Wand Maker
1
这是一个lint警告,提示你缺少这个属性 android:src="@drawable/mydrawable" - Raghunandan
1个回答

4
你需要在ImageView中设置属性 "android:contentDescription"。 例子:
<ImageView
    android:id="@+id/user_image"
    android:layout_width="30dip"
    android:layout_height="30dip" 
    android:contentDescription="@string/imageViewDescription" />

这个警告是为了确保你的ImageView通过简短的文本描述其内容。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接