Android XML format设置

android中XML的format默认的2个属性一行,如:

<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent" android:layout_height="fill_parent"
    android:stretchColumns="1" android:orientation="horizontal">


看着不方便、

 

在Eclipse中设置一下:

 Window  ->  Preferences, XML/XML Files/Editor, 勾选"Split multiple attributes each on a new line” .配置后,使用Ctrl+Shift+F 或者右键 Source -> Format 格式化就会每个属性占一行,如:

<TableLayout
	xmlns:android="http://schemas.android.com/apk/res/android"
	android:layout_width="fill_parent"
	android:layout_height="fill_parent"
	android:stretchColumns="1"
	android:orientation="horizontal">


 

另,没有子节点的元素的声明方式进行压缩如"<TextView ...></TextView>” 格式为"<TextView .../>”:

右键"Source/Cleanup Document...“, 勾选"Compress empty element tags”, OK

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章