Ctrl + Shift +F在按顺序放置java或布局文件时做得很好。但是,它是否在以<selector xmlns:android="http://schemas.android.com/apk/res/android">开头的文件(例如)中乱七八糟?
,这就是我拥有的,
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true"><nine-patch android:src="@drawable/bg_list_row_pic" />
</item>
<item><nine-patch android:src="@drawable/bg_list_row_pic" />
</item>
</selector>,这会好得多。
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true">
<nine-patch android:src="@drawable/bg_list_row_pic" />
</item>
<item>
<nine-patch android:src="@drawable/bg_list_row_pic" />
</item>
</selector>我浏览了一下Window - Preferences - XML,但没有找到任何解决问题的方法。
加法.
如果我使用Format XML files using the standard Android XML...,布局文件中有以下内容,但是包含<selector>和<item>的文件看起来是正确的(请参阅此消息中的“这会好得多”)。
,不适合我,
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_gravity="center"
android:paddingLeft="@dimen/sixteenDp" android:paddingRight="@dimen/sixteenDp">
<Button android:id="@+id/mainAct_btn_RunTest"
android:layout_width="match_parent" android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/sixteenDp" android:text="@string/run_test" />
<Button android:id="@+id/mainAct_btn_ShowList"
android:layout_width="match_parent" android:layout_height="wrap_content"
android:layout_below="@id/mainAct_btn_RunTest" android:text="@string/show_list" />
</RelativeLayout>这个布局文件适合我.
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:paddingLeft="@dimen/sixteenDp"
android:paddingRight="@dimen/sixteenDp" >
<Button
android:id="@+id/mainAct_btn_RunTest"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/sixteenDp"
android:text="@string/run_test" />
<Button
android:id="@+id/mainAct_btn_ShowList"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/mainAct_btn_RunTest"
android:text="@string/show_list" />
</RelativeLayout>发布于 2013-04-26 13:42:00
你可以试试这个。转到Windows->Preferences-> Android ->Editors,并禁用第一行“使用标准的Android格式化XML文件.”
https://stackoverflow.com/questions/16236189
复制相似问题