android:contentDescription这个属性相信大家并不陌生,在ImageButton的使用过程中如果不添加这个属性会有警告信息。
那么android:contentDescription究竟是干什么的呢?今天查了下资料才知道这个属性的真正作用。
该属性为视力障碍的用户提供方便,在为其设置文字属性后,如果用户的设备的可访问性选项作了相应的设置,那么用户点击图形按钮时,设备会读出属性值的内容。
以我的三星Galaxy s5作为样例,设置如下:
1.点击Settings—>Accessibility—>Direct access—>TalkBack—>On.
2.给你布局文件中的ImageButton增加属性android:contentDescription.
There are two ways of constructing a software design: One way is to make it so simple that there are obviously no deficiencies, and the other way is to make it so complicated that there are no obvious deficiencies. The first method is far more difficult.