[英]Eclipse disorders an XML file after pressing Ctrl + Shift + F
按順序放置java或布局文件時,Ctrl + Shift + F可以很好地完成工作。 但它是否會以<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>
你可以試試這個。 轉到Windows-> Preferences-> Android-> Editors並禁用第一行“使用標准Android XML格式化XML文件......”
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.