[Accessibility] Missing contentDescription attribute on "View"

在android ADT 16.0以後控件中沒有文本描述的view如果不加android:contentDescription="@string/**"就會有黃色的下劃線。
而android:contentDescription的屬性作用是:設置View的備註說明,作爲一種輔助功能提供,爲一些沒有文字描述的View提供說明,如ImageButton。這裏在界面上不會有效果,自己在程序中控制,可臨時放一點字符串數據,或者文字描述爲null,如:android:contentDescription=" ".

api文檔中解釋:

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.

 

 

發佈了5 篇原創文章 · 獲贊 0 · 訪問量 3萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章