Android Lint contentDescription警告

136

在使用Android Lint时,我收到了一个警告:“[Accessibility] Missing contentDescription attribute on image”,指的是ImageView缺少contentDescription属性。

这是什么意思?


5
这个警告太烦人了,特别是对于那些仅仅用于装饰的图片。 - Someone Somewhere
6
我在strings.xml文件中定义了这个:<string name="none"></string>,然后我使用了android:contentDescription="@string/none" - Someone Somewhere
11个回答

0

由于我需要在ImageView中添加一个图标,仅仅是为了美观,因此我在xml文件中的每个ImageView中添加了tools:ignore="ContentDescription"

现在我不再收到任何错误消息。


正如其他人所提到的,最好使用android:importantForAccessibility="no" - jteichert

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