神器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级