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

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