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