亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

Android——Android lint工具項目資源清理詳解

 更新時間:2016年11月16日 14:54:00   作者:dzp_coder  
這篇文章主要介紹了Android——Android lint工具項目資源清理詳解的相關(guān)資料,需要的朋友可以參考下

Android——Android lint工具項目資源清理

最近維護的項目已經(jīng)有兩年多,經(jīng)過很多前輩的迭代,項目并沒有變得健壯,而變得很臃腫.用Android lint工具清理了一次,清楚了不少廢棄的布局和資源.

1.     Android lint工具

可以右鍵項目,Android tools,退出的時候clear lint markers即可


也可以如圖:


2.結(jié)果出來了,分析分析


3.xml中view太多,已經(jīng)超過了80個,影響性能.

布局優(yōu)化:

盡量使用include、merge、ViewStub標(biāo)簽,盡量不存在冗余嵌套及過于復(fù)雜布局,盡量使用GONE替換INVISIBLE,使用weight后盡量將width和heigh設(shè)置為0dp減少運算,Item存在非常復(fù)雜的嵌套時考慮使用自定義Item View來取代,減少measure與layout次數(shù)等。

 列表及Adapter優(yōu)化;盡量復(fù)用getView方法中的相關(guān)View,不重復(fù)獲取實例導(dǎo)致卡頓,列表盡量在滑動過程中不進行UI元素刷新等。

背景和圖片等內(nèi)存分配優(yōu)化;盡量減少不必要的背景設(shè)置,圖片盡量壓縮處理顯示,盡量避免頻繁內(nèi)存抖動等問題出現(xiàn)。

自定義View等繪圖與布局優(yōu)化;盡量避免在draw、measure、layout中做過于耗時及耗內(nèi)存操作,尤其是draw方法中,盡量減少draw、measure、layout等執(zhí)行次數(shù)。 

避免ANR,不要在UI線程中做耗時操作,遵守ANR規(guī)避守則,譬如多次數(shù)據(jù)庫操作等。

activity_group_number_detail1.xml has more than 80 views, bad for performance

Issue: Checks whether a layout has too many views

Id: TooManyViews

Using too many views in a single layout is bad for performance. Consider using compound drawables or other tricks for reducing the number of views in this layout.


4.沒有定義的id,刪掉就ok

he id "top" is not defined anywhere.

Issue: Checks for id references in RelativeLayouts that are not defined elsewhere

Id: UnknownId


5.同一個XML重復(fù)定義id

在同個一個Xml文件的中如果ID同名,則前一個有效,而后一個無效

是不是復(fù)制粘貼的時候出錯了?

Duplicate id @+id/group_imageView2, already defined earlier in this layout

Issue: Checks for duplicate ids within a single layout

Id: DuplicateIds


6.ID的引用不在同一級layout中,比如說:控件A在B(B是viewgroup)的下面,而不應(yīng)該寫成A在B的子控件下面.



7.廢棄的四大組件,在mainfest.xml中沒有清掉.刪除就ok

Class referenced in the manifest, com.baidu.location.f, was not found in the project or the libraries

Issue: Ensures that classes referenced in the manifest are present in the project or libraries

Id: MissingRegistered


8.沒使用的資源,這是重頭戲,對于減小包的大小很有意義.其中包含了xml,dimens等.量比較大,建議先提交SVN之后再刪除,如果出了問題立馬可以還原.

The resource R.drawable.fc_seekbar_thumb appears to be unused

Issue: Looks for unused resources

Id: UnusedResources

9.這里檢測的結(jié)果只是提供一種參考,建議用Toast.LENGTH_SHORT或者 Toast.LENGTH_LONG


10.硬編碼的問題,使用Context.getFilesDir().getPath()

Do not hardcode "/data/"; use Context.getFilesDir().getPath() instead

Issue: Looks for hardcoded references to /sdcard

Id: SdCardPath

Your code should not reference the /sdcard path directly; instead use Environment.getExternalStorageDirectory().getPath().


11.大家一看就懂了,viewholder的問題



12.handler導(dǎo)致的內(nèi)存泄漏問題

一兩句話說不清,下面是已經(jīng)說清楚的.

http://blog.csdn.net/lijunhuayc/article/details/47999931


13.webview的父控件,寬高建議用match_parent

提示

  Placing a <WebView> in a parent element that uses a wrap_content layout_height can lead to subtle 
 bugs; use match_parent instead  

14.I18N的問題就不說了.

總結(jié):Android lint工具主要功能是規(guī)范編碼,優(yōu)化布局性能,去除無用資源.

感謝閱讀,希望能幫助到大家,謝謝大家對本站的支持!


相關(guān)文章

最新評論