Android lint 检查提示汇总
2013-01-07 11:04
459 查看
lint学习
lint
Improving Your Code with lint
Android Lint
改善提示,可以使用
这些属性设置textview的图片属性,对应的代码为TextView.setCompoundDrawable*()等。
改善后
效果图:
![](http://img.my.csdn.net/uploads/201301/06/1357459731_7406.png)
android:contentDescription
setContentDescription(CharSequence)
Making Applications Accessible
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.
Must be a string value, using '\\;' to escape characters such as '\\n' or '\\uxxxx' for a unicode character.
This may also be a reference to a resource (in the form "
or theme attribute (in the form "
This corresponds to the global attribute resource symbol
Related Methods
同时,学习一下官方文档的
不想被提示可以在eclipse中进行设置
Window->prefrences->Android->Lint Error Checking->Issues-> Accessibility->Content Decription->Severty select Ignore.
使用 android:text="@string/about_developer" 即将文本定义在string.xml文件中,然后在布局文件中引用。
4.
lint
Improving Your Code with lint
Android Lint
1. This tag and its children can be replaced by one <TextView/> and a compound drawable
xml 想要实现textview旁有个imageview标识。<LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal" android:padding="10dp" android:gravity="center_vertical"> <TextView android:id="@+id/nick_name" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginLeft="5dip" android:gravity="center_vertical" android:textAppearance="?android:attr/textAppearanceMedium" android:textColor="@color/black" android:singleLine="true" /> <ImageView android:id="@+id/_ic" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_margin="4dp" android:background="@drawable/sina_icon_small"/> </LinearLayout>
改善提示,可以使用
android:drawableTop android:drawableBottom android:drawableLeft android:drawableRight android:drawablePadding
这些属性设置textview的图片属性,对应的代码为TextView.setCompoundDrawable*()等。
改善后
<TextView android:id="@+id/nick_name" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginLeft="5dip" android:gravity="center_vertical" android:textAppearance="?android:attr/textAppearanceMedium" android:textColor="@color/black" android:singleLine="true" android:text="@string/account_center" android:drawableRight="@drawable/sina_icon_small" android:drawablePadding="4dp"/>
效果图:
![](http://img.my.csdn.net/uploads/201301/06/1357459731_7406.png)
2. [Accessibility] Missing contentDescription attribute on image
在一些不显示文本的控件中被要求添加android:contentDescription=""来描述控件的作用。android:contentDescription
setContentDescription(CharSequence)
Making Applications Accessible
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.
Must be a string value, using '\\;' to escape characters such as '\\n' or '\\uxxxx' for a unicode character.
This may also be a reference to a resource (in the form "
@[package:]type:name")
or theme attribute (in the form "
?[package:][type:]name") containing a value of this type.
This corresponds to the global attribute resource symbol
contentDescription.
Related Methods
同时,学习一下官方文档的
不想被提示可以在eclipse中进行设置
Window->prefrences->Android->Lint Error Checking->Issues-> Accessibility->Content Decription->Severty select Ignore.
3. [I18N] Hardcoded string "关于开发者", should use @string resource
不要使用 android:text="关于开发者" 这种形式使用 android:text="@string/about_developer" 即将文本定义在string.xml文件中,然后在布局文件中引用。
4.
相关文章推荐
- 定制Android-Lint检查问题的现有规则
- Android Lint 静态代码检查
- Android Lint官方静态代码检查工具
- android开发 弹出权限提示框 检查是否具有某个权限
- Android面试系列文章2018之Andrlid代码分析lint检查篇
- 百度度地图总是提示key 验证出错! 请在 AndroidManifest.xml 文件中检查 key 设置解决办法
- Android Lint 检查规则的定制(基本篇)
- 定制Android-Lint检查问题的现有规则
- 定制Android-Lint检查问题的现有规则
- Android Studio自动检查代码规范并提示如何优化的一些插件
- 用android-sdk工具里的lint检查布局的错误、警告和合理性
- 百度度地图总是提示key 验证出错! 请在 AndroidManifest.xml 文件中检查 key 设置解决办法
- Android Lint官方静态代码检查工具
- Android Studio Lint 自动检查清除冗余资源
- android开发 弹出权限提示框 检查是否具有某个权限
- Android-Lint 检查问题列表
- Android-Lint 检查问题列表
- Android静态代码检查-Lint
- 百度度地图总是提示key 验证出错! 请在 AndroidManifest.xml 文件中检查 key 设置解决办法
- Android Lint 检查规则列表