在写Android的XML布局文件时,在ImageView或ImageButton中经常会碰到一个提示: Missing contentDescription attribute on image.

在Android 的图片显示类的控件中,不写   android:contentDescription 往往会有警告(Eclipse开发时),这个属性是方便一些生理功能有缺陷的人使用应用程序的,比如一些视力有障碍的用户,如果用户安装了辅助浏览工具比如TalkBack,TalkBack就会大声朗读出用户目前正在浏览的内容。TextView控件TalkBack可以直接读出里面的内容(contentDescription的值),告诉用户这个图片到底是什么。


TalkBack的使用:

android:contentDescription 这个属性必须在用户的Accessible 中的相应属性开启后才能使用。

1. 首先下载google的应用 TalkBack (an accessibility service published by Google) 并且将功能打开 Settings > Accessibility > TalkBack 设置为On。

2.在应用中添加这个属性。

<Button
android:id=”@+id/pause_button”
android:src=”@drawable/pause”
android:contentDescription=”@string/pause”/>

3.用户点击这个控件。android系统会自动使用人声朗读控件上android:contentDescription属性说指向的内容。

这个属性的主要功能就是为视力有障碍的人增加对控件的解释。

当然不想使用这个属性时,

android:contentDescription="@null"

即可!

同样

android:background="@null"

可以去除imagebutton丑陋的背景

参考:http://blog.csdn.net/yuxiaohui78/article/details/41206179

Android:contentDescription 不是无用的更多相关文章

  1. android:contentDescription的作用是什么

    在写Android的XML布局文件时,在ImageView或ImageButton中经常会碰到一个提示: Missing contentDescription attribute on image. ...

  2. Android 控件属性介绍

    1.LinearLayout(线性布局): 可以分为水平线性:android:orientation= " horizontal " 和垂直线性:android:orientati ...

  3. android 属性

    RelativeLayout 第一类:属性值为true可false android:layout_centerHrizontal        水平居中 android:layout_centerVe ...

  4. Android 开发 View的API 转载

    转载地址:https://blog.csdn.net/lemonrabbit1987/article/details/47704679 View类代表用户界面组件的基本构建块.一个View占据屏幕上的 ...

  5. 【Android界面实现】AppWidght全面学习之电量监控小部件的实现具体解释

    版权声明:本文为博主原创文章,未经博主同意不得转载. https://blog.csdn.net/bz419927089/article/details/35791047 前几天翻看之前下载的各种资料 ...

  6. Android layout 布局 属性详解

    第一类:属性值 true或者 false           android:layout_centerHrizontal 水平居中     android:layout_centerVertical ...

  7. Android layout布局属性、标签属性总结大全

    RelativeLayout 第一类:属性值为true可false android:layout_centerHrizontal        水平居中 android:layout_centerVe ...

  8. Android中控件属性详细总结(转载)

    转载地址:https://www.cnblogs.com/nanguojs/p/5950510.html 1.LinearLayout(线性布局): 可以分为水平线性:android:orientat ...

  9. android studio你可能忽视的细节——启动白屏?drawable和mipmap出现的意义?这里都有!!!

    android studio用了很久了,也不知道各位小伙伴有没有还在用eclipse的,如果还有,楼主真心推荐转到android studio来吧,毕竟亲儿子,你会知道除了启动速度稍微慢些,你找不到一 ...

随机推荐

  1. Java读取Excel转换成JSON字符串进而转换成Java对象

    Jar包

  2. SpringBoot整合Email(电子邮件服务)

    (1).导入starter依赖 <dependency> <groupId>org.springframework.boot</groupId> <artif ...

  3. Makefile经典教程(一个很棒很清晰的讲解)【转】

    转自:https://blog.csdn.net/seven_amber/article/details/70216216 该篇文章为转载,是对原作者系列文章的总汇加上标注. 支持原创,请移步陈浩大神 ...

  4. ftruncate(改变文件大小)

    ftruncate(改变文件大小) 定义函数 int ftruncate(int fd,off_t length); 函数说明 ftruncate()会将参数fd指定的文件大小改为参数length指定 ...

  5. WebRTC服务器——Licode 环境搭建

    WebRTC服务器--Licode 环境搭建 系统配置 阿里云服务器 Ubuntu 14.04.5 LTS Docker 环境搭建 在一台空的机器上搭建docker环境,先要安装docker,执行下面 ...

  6. centos6.5环境使用RPM包离线安装MariaDB 10.0.20

    1. 进入MariaDB官网下载MariaDB需要的RPM包 2. 使用下载软件下载所需要的RPM包, 总共4个, 并上传到CentOS主机指定目录. MariaDB-10.0.20-centos6- ...

  7. 转载:2.2.4 配置项的单位《深入理解Nginx》(陶辉)

    原文:https://book.2cto.com/201304/19629.html 大部分模块遵循一些通用的规定,如指定空间大小时不用每次都定义到字节.指定时间时不用精确到毫秒. 当指定空间大小时, ...

  8. Day5-----------------------系统监控

    1.top 命令 查看终端信息 who 显示终端用户有哪些 bash 开启终端进程 PID:进程身份证 buffer:缓冲区 cache:高速缓存 进程:动起来的文件,CPU调用运行的过程 2.fre ...

  9. 洛谷 P4427 求和

    传送门啦 思路: 开始不肿么容易想到用倍增,但是想到需要求 $ Lca $ ,倍增这种常数小而且快的方法就很方便了.求 $ Lca $ 就是一个最普通的板子.那现在考虑怎么求题目中的结果. 树上差分可 ...

  10. ubuntu 电源管理

    https://www.cnblogs.com/sky-heaven/p/4561374.html?tdsourcetag=s_pcqq_aiomsg  挂起命令 echo mem > /sys ...