【Android】使用layoutopt.bat优化布局

神器layoutopt.bat存放在\android-sdk-windows\tools目录内,

运行此神器可以检查出你写的XML布局不合理之处,

如图:

        69:80 This tag and its children can be replaced by one <TextView/> and a
 compound drawable

比如上两行表明:在main.xml的69行到80行:这些标签和子控件可以用一个<TextView/>和一个混合图片来代替,

好吧,给出main.xml的69行到80行的代码:

        <LinearLayout
            android:id="@+id/main_layout_1"
            style="@style/main_layout" >

            <ImageView
                android:id="@+id/main_btn_zhxx"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:src="@drawable/zhonghixinxi_btn_selector" />

            <TextView
                style="@style/main_textview"
                android:text="综合信息" />
        </LinearLayout>

敢脚蛮屌的!

 

以下是使用layoutopt.bat的方法:

1.进入CMD

2.CD进入\android-sdk-windows\tools目录

3.键入

layoutopt <file_or_directory> ...

如layoutopt E:\workspace\DCBIZ\res\layout\main.xml

 

常见的提示还有:

1.有多余的Layout

2.视图过多,超过80多

3.布局嵌套太多,超过10级

 

 

 

 


 


 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值