国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 系統(tǒng) > Android > 正文

詳解Android布局優(yōu)化

2019-10-22 18:13:44
字體:
來源:轉載
供稿:網(wǎng)友

怎樣才能寫出優(yōu)秀的Android App,是每一個程序員追求的目標。那么怎么才能寫出一個優(yōu)秀的App呢?相信很多初學者也會有這種迷茫。一句話來回答這個問題:細節(jié)很重要。今天我們就從最基礎的XML布局來談談怎么提高Android性能問題吧!

也許你經(jīng)常會遇到比較復雜的布局,這種情況下,最簡單的方法就是多層嵌套實現(xiàn)效果,但是最簡單的方法是否是最優(yōu)的方法呢? 這里需要打一個大大的問號?????經(jīng)驗告訴我們,往往簡單的方法,得到的結果不是最優(yōu)解,那么我們通過一個例子來研究一下怎么去優(yōu)化我們的XML布局吧,下面通過經(jīng)典微信中的“發(fā)現(xiàn)”tab頁面中的布局來看看怎么實現(xiàn)。

Android,布局優(yōu)化

上面這張圖片是微信界面截圖,看到這張效果圖的第一眼會讓開發(fā)者想到使用線性布局實現(xiàn)這種左邊圖片,右邊文字,一行白色背景效果很方便。那么我們就按照一般思路寫出如下布局代碼:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@color/color_eeeeee" android:orientation="vertical" tools:context=".MainActivity"> <LinearLayout  android:layout_width="match_parent"  android:layout_height="0dp"  android:layout_weight="1"  android:orientation="vertical">  <LinearLayout   android:layout_width="match_parent"   android:layout_height="wrap_content"   android:layout_marginTop="20dp"   android:background="@drawable/item_bg_select"   android:clickable="true"   android:gravity="center_vertical"   android:orientation="horizontal"   android:paddingLeft="20dp"   android:paddingRight="20dp">   <ImageView    android:layout_width="wrap_content"    android:layout_height="wrap_content"    android:src="@drawable/afe" />   <TextView    android:layout_width="wrap_content"    android:layout_height="wrap_content"    android:layout_marginLeft="15dp"    android:text="@string/fiends"    android:textColor="@android:color/black"    android:textSize="16sp" />  </LinearLayout>  <LinearLayout   android:layout_width="match_parent"   android:layout_height="wrap_content"   android:layout_marginTop="20dp"   android:background="@android:color/white"   android:orientation="vertical">   <LinearLayout    android:layout_width="match_parent"    android:layout_height="wrap_content"    android:background="@drawable/item_bg_select"    android:clickable="true"    android:gravity="center_vertical"    android:orientation="horizontal"    android:paddingLeft="20dp"    android:paddingRight="20dp">    <ImageView     android:layout_width="wrap_content"     android:layout_height="wrap_content"     android:src="@drawable/afg" />    <TextView     android:layout_width="wrap_content"     android:layout_height="wrap_content"     android:layout_marginLeft="15dp"     android:text="@string/scan"     android:textColor="@android:color/black"     android:textSize="16sp" />   </LinearLayout>   <View    android:layout_width="match_parent"    android:layout_height="0.5dp"    android:layout_marginLeft="10dp"    android:layout_marginRight="10dp"    android:background="@color/color_e0e0e0"></View>   <LinearLayout    android:layout_width="match_parent"    android:layout_height="wrap_content"    android:background="@drawable/item_bg_select"    android:clickable="true"    android:gravity="center_vertical"    android:orientation="horizontal"    android:paddingLeft="20dp"    android:paddingRight="20dp">    <ImageView     android:layout_width="wrap_content"     android:layout_height="wrap_content"     android:src="@drawable/afh" />    <TextView     android:layout_width="wrap_content"     android:layout_height="wrap_content"     android:layout_marginLeft="15dp"     android:text="@string/shake"     android:textColor="@android:color/black"     android:textSize="16sp" />   </LinearLayout>  </LinearLayout>  <LinearLayout   android:layout_width="match_parent"   android:layout_height="wrap_content"   android:layout_marginTop="20dp"   android:background="@android:color/white"   android:orientation="vertical">   <LinearLayout    android:layout_width="match_parent"    android:layout_height="wrap_content"    android:background="@drawable/item_bg_select"    android:clickable="true"    android:gravity="center_vertical"    android:orientation="horizontal"    android:paddingLeft="20dp"    android:paddingRight="20dp">    <ImageView     android:layout_width="wrap_content"     android:layout_height="wrap_content"     android:src="@drawable/afd" />    <TextView     android:layout_width="wrap_content"     android:layout_height="wrap_content"     android:layout_marginLeft="15dp"     android:text="@string/nearby"     android:textColor="@android:color/black"     android:textSize="16sp" />   </LinearLayout>   <View    android:layout_width="match_parent"    android:layout_height="0.5dp"    android:layout_marginLeft="10dp"    android:layout_marginRight="10dp"    android:background="@color/color_e0e0e0"></View>   <LinearLayout    android:layout_width="match_parent"    android:layout_height="wrap_content"    android:background="@drawable/item_bg_select"    android:clickable="true"    android:gravity="center_vertical"    android:orientation="horizontal"    android:paddingLeft="20dp"    android:paddingRight="20dp">    <ImageView     android:layout_width="wrap_content"     android:layout_height="wrap_content"     android:src="@drawable/afb" />    <TextView     android:layout_width="wrap_content"     android:layout_height="wrap_content"     android:layout_marginLeft="15dp"     android:text="@string/float_bottle"     android:textColor="@android:color/black"     android:textSize="16sp" />   </LinearLayout>  </LinearLayout>  <LinearLayout   android:layout_width="match_parent"   android:layout_height="wrap_content"   android:layout_marginTop="20dp"   android:background="@android:color/white"   android:orientation="vertical">   <LinearLayout    android:layout_width="match_parent"    android:layout_height="wrap_content"    android:background="@drawable/item_bg_select"    android:clickable="true"    android:gravity="center_vertical"    android:orientation="horizontal"    android:paddingLeft="20dp"    android:paddingRight="20dp">    <ImageView     android:layout_width="wrap_content"     android:layout_height="wrap_content"     android:src="@drawable/agg" />    <TextView     android:layout_width="wrap_content"     android:layout_height="wrap_content"     android:layout_marginLeft="15dp"     android:text="@string/shopping"     android:textColor="@android:color/black"     android:textSize="16sp" />   </LinearLayout>   <View    android:layout_width="match_parent"    android:layout_height="0.5dp"    android:layout_marginLeft="10dp"    android:layout_marginRight="10dp"    android:background="@color/color_e0e0e0"></View>   <LinearLayout    android:layout_width="match_parent"    android:layout_height="wrap_content"    android:background="@drawable/item_bg_select"    android:clickable="true"    android:gravity="center_vertical"    android:orientation="horizontal"    android:paddingLeft="20dp"    android:paddingRight="20dp">    <ImageView     android:layout_width="wrap_content"     android:layout_height="wrap_content"     android:src="@drawable/ak6" />    <TextView     android:layout_width="wrap_content"     android:layout_height="wrap_content"     android:layout_marginLeft="15dp"     android:text="@string/games"     android:textColor="@android:color/black"     android:textSize="16sp" />   </LinearLayout>  </LinearLayout> </LinearLayout> <LinearLayout  android:layout_width="match_parent"  android:layout_height="wrap_content"  android:background="@android:color/white"  android:orientation="horizontal">  <TextView   android:layout_width="0dp"   android:layout_height="wrap_content"   android:layout_weight="1"   android:drawableTop="@drawable/ala"   android:gravity="center"   android:text="@string/weixin"   android:textColor="@color/color_9e9e9e" />  <TextView   android:layout_width="0dp"   android:layout_height="wrap_content"   android:layout_weight="1"   android:drawableTop="@drawable/al9"   android:gravity="center"   android:text="@string/countans"   android:textColor="@color/color_9e9e9e" />  <TextView   android:layout_width="0dp"   android:layout_height="wrap_content"   android:layout_weight="1"   android:drawableTop="@drawable/alc"   android:gravity="center"   android:text="@string/finds"   android:textColor="@color/color_9e9e9e" />  <TextView   android:layout_width="0dp"   android:layout_height="wrap_content"   android:layout_weight="1"   android:drawableTop="@drawable/ale"   android:gravity="center"   android:text="@string/me"   android:textColor="@color/color_9e9e9e" /> </LinearLayout></LinearLayout>

以上布局的效果圖如下:

Android,布局優(yōu)化

是不是差不多實現(xiàn)了微信一樣的效果?那么我們怎么來判斷以上布局是不是最優(yōu)的呢?當然,我們是有工具來查看的。相信很多童鞋用過了,第一個就是 Hierarchy View,第二個就是 顯示GPU過度繪制。

Hierarchy View檢測布局嵌套層次

如果你是使用AS開發(fā)的話,你可以在 AS 工具欄中點擊 Tools–>Android–>Android Device Monitor–>Hierarchy View。(至于Hierarchy View怎么使用這里就不仔細介紹了)你可以通過這個工具來查看當前布局的層次結構,如下圖的布局的層次結構就是上面微信的布局:

Android,布局優(yōu)化

ContentFrameLayout接點之后就是我們上面XML代碼的布局了,從上圖可以看到,我們布局最多有 5 層,其實你從代碼中也可以看到是 5 層,那么我們是否能減少以上的布局的嵌套層次呢?答案是肯定的,廢話不多說,我們直接上一份我優(yōu)化過的布局代碼吧。

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@color/color_eeeeee" tools:context=".MainActivity"> <TextView  android:id="@+id/tv_one"  style="@style/textStyle"  android:layout_marginTop="20dp"  android:background="@drawable/item_bg_select"  android:drawableLeft="@drawable/afe"  android:text="@string/fiends" /> <android.support.v7.widget.LinearLayoutCompat  android:id="@+id/lv_two"  style="@style/LinerLayoutStyle"  android:layout_below="@+id/tv_one"  app:divider="@drawable/lines"  app:dividerPadding="10dp"  app:showDividers="middle">  <TextView   style="@style/textStyle"   android:background="@drawable/item_bg_select"   android:drawableLeft="@drawable/afg"   android:text="@string/scan" />  <TextView   style="@style/textStyle"   android:background="@drawable/item_bg_select"   android:drawableLeft="@drawable/afh"   android:text="@string/shake" /> </android.support.v7.widget.LinearLayoutCompat> <android.support.v7.widget.LinearLayoutCompat  android:id="@+id/lv_threed"  style="@style/LinerLayoutStyle"  android:layout_below="@+id/lv_two"  app:divider="@drawable/lines"  app:dividerPadding="10dp"  app:showDividers="middle">  <TextView   style="@style/textStyle"   android:background="@drawable/item_bg_select"   android:drawableLeft="@drawable/afd"   android:text="@string/nearby" />  <TextView   style="@style/textStyle"   android:background="@drawable/item_bg_select"   android:drawableLeft="@drawable/afb"   android:text="@string/float_bottle" /> </android.support.v7.widget.LinearLayoutCompat> <android.support.v7.widget.LinearLayoutCompat  style="@style/LinerLayoutStyle"  android:layout_below="@+id/lv_threed"  app:divider="@drawable/lines"  app:dividerPadding="10dp"  app:showDividers="middle">  <TextView   style="@style/textStyle"   android:background="@drawable/item_bg_select"   android:drawableLeft="@drawable/agg"   android:text="@string/shopping" />  <TextView   style="@style/textStyle"   android:background="@drawable/item_bg_select"   android:drawableLeft="@drawable/ak6"   android:text="@string/games" /> </android.support.v7.widget.LinearLayoutCompat> <include  layout="@layout/bottom_layout"  android:layout_width="match_parent"  android:layout_height="wrap_content"  android:layout_alignParentBottom="true" /></RelativeLayout>

哇,代碼量少了很多啊,代碼也簡潔了許多,讓人看著就很舒服,那么我們到底進行了怎樣的優(yōu)化呢?從以下幾點總結:

使用 style 主題來定義一個通用的屬性,從而重復利用代碼,減少代碼量。上面代碼使用了兩個style,一個是textStyle 和 LinerLayoutStyle ,代碼如下:

<!--TextView 的通用屬性--> <style name="textStyle">  <item name="android:layout_width">match_parent</item>  <item name="android:layout_height">wrap_content</item>  <item name="android:textSize">16sp</item>  <item name="android:textColor">@android:color/black</item>  <item name="android:paddingRight">20dp</item>  <item name="android:paddingLeft">20dp</item>  <item name="android:gravity">center_vertical</item>  <item name="android:clickable">true</item> </style> <!--LinerLayout 的通用屬性--> <style name="LinerLayoutStyle" >  <item name="android:layout_width">match_parent</item>  <item name="android:layout_height">wrap_content</item>  <item name="android:layout_marginTop">20dp</item>  <item name="android:background">@android:color/white</item>  <item name="android:orientation">vertical</item> </style>

2.減少布局嵌套的層次,上面布局使用TextView可以設置四個方向圖片來直接替代LinerLayout下包裹一個ImageView 和TextView。從而這里減少了一層嵌套布局,再次利用RelativeLayout相對布局又減少了一層橋套,提高了加載布局的效率。看圖:

Android,布局優(yōu)化

從圖中看出,不僅減少了兩層嵌套布局,而且組件數(shù)目也減少,從而減少布局繪制的時間,大大提高了布局加載效率。

3.使用 LinearLayoutCompat 組件來實現(xiàn)線性布局元素之間的分割線,從而減少了使用View來實現(xiàn)分割線效果。

LinearLayoutCompat的具體內(nèi)容請參考http://www.survivalescaperooms.com/article/137253.htm

4.使用 include 標簽加載底部菜單欄布局,include 標簽的目的是重復利用布局,來減少代碼了。

<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="wrap_content" android:background="@android:color/white" android:orientation="horizontal"> <TextView  android:layout_width="0dp"  android:layout_height="wrap_content"  android:layout_weight="1"  android:drawableTop="@drawable/ala"  android:gravity="center"  android:text="@string/weixin"  android:textColor="@color/color_9e9e9e"   /> <TextView  android:layout_width="0dp"  android:layout_height="wrap_content"  android:layout_weight="1"  android:drawableTop="@drawable/al9"  android:gravity="center"  android:text="@string/countans"  android:textColor="@color/color_9e9e9e" /> <TextView  android:layout_width="0dp"  android:layout_height="wrap_content"  android:layout_weight="1"  android:drawableTop="@drawable/alc"  android:gravity="center"  android:text="@string/finds"  android:textColor="@color/color_9e9e9e" /> <TextView  android:layout_width="0dp"  android:layout_height="wrap_content"  android:layout_weight="1"  android:drawableTop="@drawable/ale"  android:gravity="center"  android:text="@string/me"  android:textColor="@color/color_9e9e9e" /></LinearLayout>

5.使用merge減少布局嵌套層次。

使用merge的前提條件就是merge標簽必須是當前xml布局的根標簽,例如:

<merge xmlns:android="http://schemas.android.com/apk/res/android"> ........</merge> 

也就是merge標簽必須是當前布局的父布局。一般merge標簽和include結合使用來減少布局嵌套層次。例如有如下布局:兩個Button,以上一下。

<?xml version="1.0" encoding="utf-8"?><RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"    android:layout_width="match_parent"    android:layout_height="match_parent"> <RelativeLayout  android:layout_width="match_parent"  android:layout_height="match_parent">  <Button   android:id="@+id/button1"   android:layout_width="wrap_content"   android:layout_height="wrap_content"   android:text="text1"/>  <Button   android:id="@+id/button2"   android:layout_width="wrap_content"   android:layout_height="wrap_content"   android:layout_below="@+id/button1"   android:text="text2"/> </RelativeLayout></RelativeLayout>

該布局層次如下:

Android,布局優(yōu)化

由上圖看出除了根布局,我們自己寫的布局有三層,兩層都是RelativeLayout。那么能否優(yōu)化呢?

(1)首先我們可以利用include標簽簡化xml布局。結果變成如下:

<?xml version="1.0" encoding="utf-8"?><RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"    android:layout_width="match_parent"    android:layout_height="match_parent"> <include layout="@layout/layout_item"></include></RelativeLayout>

代碼很清爽有木有,一目了然。然后layout_item布局如下:

<?xml version="1.0" encoding="utf-8"?><RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"    android:layout_width="match_parent"    android:layout_height="match_parent"> <Button  android:id="@+id/button1"  android:layout_width="wrap_content"  android:layout_height="wrap_content"  android:text="text1"/> <Button  android:id="@+id/button2"  android:layout_width="wrap_content"  android:layout_height="wrap_content"  android:layout_below="@+id/button1"  android:text="text2"/></RelativeLayout>

到此,其實布局的嵌套層次和上面一樣沒有任何改變。那么我們利用merge標簽來試試看結果怎樣?merge標簽代碼如下:

<?xml version="1.0" encoding="utf-8"?><merge xmlns:android="http://schemas.android.com/apk/res/android"    android:layout_width="match_parent"    android:layout_height="match_parent"> <Button  android:id="@+id/button1"  android:layout_width="wrap_content"  android:layout_height="wrap_content"  android:text="text1"/> <Button  android:id="@+id/button2"  android:layout_width="wrap_content"  android:layout_height="wrap_content"  android:layout_below="@+id/button1"  android:text="text2"/></merge>

此處僅僅把RelativeLayout標簽換成merge標簽,效果卻大有不同。

利用merge標簽以后的布局層次如下:

Android,布局優(yōu)化

很明顯減少了一層RelativeLayout布局,從而優(yōu)化了布局。

總結:當父布局和子布局的根布局是同一種布局時,可以利用merge標簽來減少一層嵌套布局。比如:你父布局是LinerLayout,此時子布局也是LinerLayout,就可以考慮使用merge來減少布局嵌套層次。

顯示GPU過度繪制

你可以在手機打開 設置—->開發(fā)者選項—->顯示GPU過度繪制,這個開關的作用是按不同顏色值來顯示布局的過度繪制,繪制的層次從最優(yōu)到最差:藍,綠,淡紅,紅。給出一張直觀的形象圖片來表示吧

Android,布局優(yōu)化

圖片從上到下代表不同層次的OverDraw,我們在布局時候,盡量減少紅色 Overdraw,看到更多的藍色區(qū)域。來看看微信的 Overdraw圖和我們自定義的布局Overdraw圖吧

Android,布局優(yōu)化

Android,布局優(yōu)化

第一張圖是 騰訊微信的Overdraw 圖,第二張圖片是我們自定義的 Overdraw 圖片。從上面兩張圖片看出,我們自己的布局和微信原版的布局 Overdraw 過度繪制情況差不多,沒啥區(qū)別。那么我們能不能去減少紅色部分的過度繪制呢?試試吧!

我們先去掉最頂端布局RelativeLayout的背景

android:background="@color/color_eeeeee"

然后修改每個item選擇資源 selector

android:background="@drawable/item_bg_select1"

之前的 item_bg_select.xml 資源是如下代碼:

<?xml version="1.0" encoding="utf-8"?><selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:drawable="@color/color_e0e0e0" android:state_pressed="true"></item> <item android:drawable="@android:color/white"></item></selector>

修改之后的 item_bg_select1.xml資源代碼如下:

<?xml version="1.0" encoding="utf-8"?><selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:drawable="@color/color_e0e0e0" android:state_pressed="true"></item></selector>

我們發(fā)現(xiàn),新的 selector資源去除了

<item android:drawable="@android:color/white"></item>

因為整個背景是白色的,無需重復設置正常情況下item的背景顏色。

修改之后的效果圖如下:

Android,布局優(yōu)化

看出,基本沒有紅色區(qū)域,從而提高布局的繪制效率。

總結:現(xiàn)在看來,我們通過減少背景顏色的設置來減少Overdraw的情況。我們自己布局過度繪制的情況比微信本身的情況有很大的改善,是不是感覺很nice~~。

懶加載布局 ViewStub

除了以上兩種方法來優(yōu)化布局,還有其他辦法來繼續(xù)優(yōu)化布局,在某些情況下,有些布局是僅在需要時才加載,比如小米手機的添加聯(lián)系人功能就有在編輯姓名的時候有一個下拉按鈕顯示更多輸入信息,看圖

Android,布局優(yōu)化

Android,布局優(yōu)化

遇到這種情況,我們首先想到的 就是將不常用的元素使用INVISIBLE或者GONE進行隱藏,這樣是否真的好呢?是否達到了 布局優(yōu)化的最終效果呢?利用 INVISIBLE只是隱藏布局,但是布局還是占居當前位置,且系統(tǒng)在加載布局的時候這一部分還是會繪制出來,同樣花費繪制時間。那么有沒有好的辦法來解決這一問題呢?不言而喻,我們可以使用懶加載布局 ViewStub。

ViewStub是Android為此提供了一種非常輕量級的控件。ViewStub雖說也是View的一種,但是它沒有大小,沒有繪制功能,也不參與布局,資源消耗非常低,將它放置在布局當中基本可以認為是完全不會影響性能的。

下面我們來學習一下 ViewStub的使用方法吧!

<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" android:padding="20dp"> <EditText  android:id="@+id/et_name"  android:layout_width="150dp"  android:drawableRight="@drawable/a0e"  android:layout_height="wrap_content"  android:hint="@string/name" /> <ViewStub  android:id="@+id/view_stub"  android:layout_width="wrap_content"  android:layout_height="wrap_content"  android:layout="@layout/item_name" /> <EditText  android:layout_width="150dp"  android:layout_height="wrap_content"  android:hint="@string/comp" /> <EditText  android:layout_width="150dp"  android:layout_height="wrap_content"  android:hint="@string/lead" /></LinearLayout>

item_name.xml 布局如下:

<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> <EditText  android:id="@+id/et_name1"  android:layout_width="150dp"  android:layout_height="wrap_content"  android:hint="@string/name1" /> <EditText  android:id="@+id/et_name2"  android:layout_width="150dp"  android:layout_height="wrap_content"  android:hint="@string/name2" /> <EditText  android:id="@+id/et_name3"  android:layout_width="150dp"  android:layout_height="wrap_content"  android:hint="@string/name3" /> <EditText  android:id="@+id/et_name4"  android:layout_width="150dp"  android:layout_height="wrap_content"  android:hint="@string/name4" /></LinearLayout>

然后你在代碼中這么使用即可

findViewById(R.id.et_name).setOnClickListener(new View.OnClickListener() {   @Override   public void onClick(View v) {    ViewStub viewStub = (ViewStub) findViewById(R.id.view_stub);    if (null != viewStub) {     //主要是這一句顯示更多布局     View view = viewStub.inflate();     EditText name1 = (EditText) view.findViewById(R.id.et_name1);     EditText name2 = (EditText) view.findViewById(R.id.et_name2);     EditText name3 = (EditText) view.findViewById(R.id.et_name3);     EditText name4 = (EditText) view.findViewById(R.id.et_name4);    }   }  });

效果圖如下:

Android,布局優(yōu)化

Android,布局優(yōu)化

從效果圖可以看出,當用戶點擊姓名下拉按鈕時,其他關于姓名的布局就加載出來了,而且原來的布局是顯示在ViewStub布局之下的,位置顯示沒有任何異常。當然你可以通過 setVisibility(View.VISIBLE)或者viewStub.inflate()方來來讓其顯示,通過setVisibility(View.INVISIBLE)來隱藏 ViewStub。

Android Lint 工具

這里不展開介紹 Lint 工具,感興趣的童鞋可以自己網(wǎng)上搜索一把,這個工具主要是用來檢查工程中代碼的不合理,布局不合理,資源重復,圖片重復,等,讓開發(fā)者進一步優(yōu)化自己的應用。如果你是AS 用戶,你可以在工具欄 Analyze—>Inspect Code 打開此工具使用。


注:相關教程知識閱讀請移步到Android開發(fā)頻道。
發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 宜君县| 辽阳县| 皮山县| 达拉特旗| 那曲县| 凤阳县| 揭西县| 丹棱县| 庄河市| 双江| 吉林市| 兴义市| 龙口市| 德化县| 阜南县| 外汇| 诸城市| 广水市| 桃源县| 陈巴尔虎旗| 慈溪市| 罗平县| 鹰潭市| 永安市| 如东县| 当涂县| 巩留县| 西峡县| 石狮市| 金湖县| 凭祥市| 青岛市| 南丰县| 峨山| 贡嘎县| 全南县| 铜鼓县| 邹平县| 左贡县| 金华市| 神木县|