標籤: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工具 檢查的常見問題