码迷,mamicode.com
首页 > 移动开发 > 详细

Android lint工具 检查的常见问题

时间:2014-11-03 16:28:50      阅读:196      评论:0      收藏:0      [点我收藏+]

标签:des   android   blog   io   ar   使用   java   for   sp   

 1. Correctness  
1) DuplicatedIds  
Layout中id应该唯一  
2) NewApi  
代码中使用的某些API高于Manifest中的Min SDK  
3) InconsistentArrays  
字符串国际化中,同一名字的的String-Array对应的item值不相同  
4) Registered  
Activity/Service/ContentProvider没有通过AndroidManifest注册  
5) Deprecated  
使用已经废弃的API  
6) PxUsage  
避免使用px,使用dp  
   
2. Correctness:Messeges  
1) MissingTranslation  
字符串国际化不完全  
2) ExtraTranslation  
国际化的字符串,在默认位置(defaultlocale),没有定义  
   
3. Security  
1) SetJavaScriptEnabled  
不确定你的程序中确实需要JavaScript就不要执行SetJavaScriptEnabled。  
2)ExportedContentProvider/ExportedReceiver/ExportedService/ExportedActivity  
ContentProvider/Receiver/Service/Activity的exported为true时,设置一个Permission,让使用者获取了Permission才能使用。  
3) HardcodedDebugMode  
不要在manifest中设置android:debuggable。  
设置它,编译的任何版本都要采用指定的debug模式。不设置,编译Eng版本采用debug模式;编译User版本采用release模式。  
   
4. Performance  
1) DrawAllocation  
避免在绘制或者解析布局(draw/layout)时分配对象。E.g.,Ondraw()中实例化Paint对象。  
2) ObsoleteLayoutParam  
Layout中无用的参数。  
3) UseCompoundDrawables  
可优化的布局:如包含一个Imageview和一个TextView的线性布局,可被采用CompoundDrawable的TextView代替。  
4) UseSparseArrays  
尽量用Android的SparseArray代替Hashmap  
5) DisableBaselineAlignment  
如果LinearLayout被用于嵌套的layout空间计算,它的android:baselineAligned属性应该设置成false,以加速layout计算。  
6) FloatMath  
使用FloatMath代替Math。  
7) NestedWeights  
避免嵌套weight,那将拖累执行效率  
8) UnusedResources/UnusedIds  
未被使用的资源会是程序变大,并且编译速度降低。  
9) Overdraw  
如果为RootView指定一个背景Drawable,会先用Theme的背景绘制一遍,然后才用指定的背景,这就是所谓的“Overdraw”。  
可以设置theme的background为null来避免。  
10) UselessLeaf/UselessParent  
View或view的父亲没有用  
   
5. Usability:Typography  
1) TypographyDashes  
特殊字符需用编码代替:“–”需要用“–”;“—”需要用“—”  
2) TypographyEllipsis  
特殊字符需用编码代替:“…”需要用“…”  
3) TypographyOther  
问题:“(c)”需要用“©”  
   
6. Usability:Icons  
1) IconNoDpi  
Icon在nodpi和指定dpi的目录下都出现。  
2) GifUsage  
Image不要用GIF,最好用PNG,可以用JPG。  
   
7. Usability  
1) BackButton  
Android中不要设计有Back的按钮,Android中一般有Back的硬按键。  
2) ButtonCase  
Button的“Ok”/“Cancel”显示大小写一定,不要全大写或全小写。有标准的资源的字符串,不要自己再定义,而要用系统定义的:@android:string/ok和@android:string/cancel  
   
8. Accessibility  
1) ContentDescription  
ImageView和ImageButton应该提供contentDescription  
   
9. Internationalization  
1) HardcodeText  
硬编码的字符串应该在资源里定义  
2) EnforceUTF8  
所有XML资源文件都应该以UTF-8编码  


Android lint工具 检查的常见问题

标签:des   android   blog   io   ar   使用   java   for   sp   

原文地址:http://blog.csdn.net/honjane/article/details/40741215

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!