开发程序时,在main.xml中添加控件imagebutton时会有一下警告:
missing contentdescription attribute on image
起初不知道怎么办
后来查了一下文档知道了,官方解释如下:
resolved this warning by setting attribute android:contentdescription for my imageview
android:contentdescription="@string/desc"
android lint support in adt 16 throws this warning to ensure that image widgets provide a contentdescription
this 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.
non-textual widgets like imageviews and imagebuttons should use the contentdescription attribute to specify a textual description of the widget such that screen readers and other accessibility tools can adequately describe the user interface.
大体翻译一下:
解决警告missing contentdescription attribute on image的方法是添加一下代码
android:contentdescription="@string/desc"(注意,这里的desc指的是你对自己程序的描述,这段描述定义在string.xml里面)
提示:其实这段描述是什么这个不重要,你可以引用string里面的任何一个字符串
安卓Android 的这个adt16发出这个警告的目的是为了让你对已定义的image控件进行描述
控件的这一特性主要是起到辅助作用的。由于无文本控件没有描述性功能的文字说明,所以imagebutton,imageview这些控件描述性的定义就能起到与代码阅读者或者是其他工具进行衔接的功能!