在XML中“缺失的图像contentDescription属性” [英] 'Missing contentDescription attribute on image' in XML

查看:1085
本文介绍了在XML中“缺失的图像contentDescription属性”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我得到关于 [辅助]缺少contentDescription的图片在eclipse属性的警告。该警告显示,在5号线(声明的ImageView )以下XML code。

这没有任何错误时的构建和运行我的应用程序。但我真的想知道为什么我得到这样的警告。

这是我的XML文件:

 < XML版本=1.0编码=UTF-8&GT?;
< LinearLayout中的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android
              机器人:layout_width =FILL_PARENT
              机器人:layout_height =WRAP_CONTENT>
    < ImageView的
        机器人:ID =@ + ID / contact_entry_image
        机器人:SRC =@可绘制/ ic_launcher
        机器人:layout_width =WRAP_CONTENT
        机器人:layout_height =WRAP_CONTENT
        />
    <的TextView
        机器人:ID =@ + ID / contact_entry_text
        机器人:文本=
        机器人:layout_width =FILL_PARENT
        机器人:layout_height =WRAP_CONTENT
        机器人:TEXTSIZE =30sp
        />

< / LinearLayout中>
 

请帮我对此并感谢您的阅读。

解决方案

我想请点击此链接的解决方案: Android的皮棉contentDescription警告

  

通过设置属性的Andr​​oid解决此警告:contentDescription   我的ImageView的

     

安卓contentDescription =@字符串/递减

     

Android的皮棉支持ADT 16抛出这样的警告,以保证   图像小部件提供contentDescription

     

这定义文本简要介绍了视图的内容。本   物业主要用于无障碍。由于一些看法不   有文字再presentation这个属性可以被用于提供   这样的。

     

非文本的小部件一样ImageViews和ImageButtons应该使用   contentDescription属性指定的文本描述   窗口小部件,使得屏幕阅读器等辅助工具就可以   充分地描述的用户界面。

此链接解释: <一个href="http://developer.android.com/guide/topics/ui/accessibility/index.html">http://developer.android.com/guide/practices/design/accessibility.html

  

很多Android用户都要求他们互动残疾人   以不同的方式他们的Andr​​oid设备。这些措施包括用户谁   有视觉,身体或与年龄有关的障碍即prevent它们   从充分看见或使用触摸屏

     

Android提供的辅助功能和服务,帮助这些   用户浏览他们的设备更容易,包括文本到语音,   触觉反馈,轨迹球和D-垫导航是增加他们的   经验。 Android应用程序开发人员可以利用这些   服务,使他们的应用程序更容易,也建立   他们自己的辅助服务。

和本指南,让你的应用程序可以访问: <一个href="http://developer.android.com/guide/topics/ui/accessibility/apps.html">http://developer.android.com/guide/topics/ui/accessibility/apps.html

  

确保您的应用程序可以访问到所有用户比较   容易,特别是当你使用框架提供的用户界面   组件。如果您只使用这些标准组件为您   应用程序中,有刚需,确保了几步您   应用程序可以访问:

     
      
  1. 标签您的的ImageButton 的ImageView 的EditText 复选框和其他用户   使用界面控件在机器人:contentDescription 属性

  2.   
  3. 请所有的用户界面元素具有方向性访问   控制器,诸如轨迹球或D垫

  4.   
  5. 通过打开辅助服务,如话语提示测试应用程序   和触摸浏览,   并尝试使用只用定向控制您的应用程序。

  6.   

I get an warning about [Accessibility]Missing contentDescription attribute on image in eclipse. This warning show at line 5 (declare ImageView) in XML code below.

This not make any error when build and run my application. But I really want to know why i get this warning.

This is my XML file:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
              android:layout_width="fill_parent"
              android:layout_height="wrap_content">
    <ImageView
        android:id="@+id/contact_entry_image"
        android:src="@drawable/ic_launcher"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        />
    <TextView
        android:id="@+id/contact_entry_text"
        android:text=""
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:textSize="30sp"
        />

</LinearLayout>

Please help me regarding this and thanks for your reading.

解决方案

I thinks follow this link for solution: Android Lint contentDescription warning

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.

this link for explanation: http://developer.android.com/guide/practices/design/accessibility.html

Many Android users have disabilities that require them to interact with their Android devices in different ways. These include users who have visual, physical or age-related disabilities that prevent them from fully seeing or using a touchscreen.

Android provides accessibility features and services for helping these users navigate their devices more easily, including text-to-speech, haptic feedback, trackball and D-pad navigation that augment their experience. Android application developers can take advantage of these services to make their applications more accessible and also build their own accessibility services.

and this guide is for making your app accessible: http://developer.android.com/guide/topics/ui/accessibility/apps.html

Making sure your application is accessible to all users is relatively easy, particularly when you use framework-provided user interface components. If you only use these standard components for your application, there are just a few steps required to ensure your application is accessible:

  1. Label your ImageButton, ImageView, EditText, CheckBox and other user interface controls using the android:contentDescription attribute.

  2. Make all of your user interface elements accessible with a directional controller, such as a trackball or D-pad.

  3. Test your application by turning on accessibility services like TalkBack and Explore by Touch, and try using your application using only directional controls.

这篇关于在XML中“缺失的图像contentDescription属性”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆