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