首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Eclipse在按Ctrl + Shift +F后扰乱XML文件

Eclipse在按Ctrl + Shift +F后扰乱XML文件
EN

Stack Overflow用户
提问于 2013-04-26 12:13:41
回答 1查看 211关注 0票数 0

Ctrl + Shift +F在按顺序放置java或布局文件时做得很好。但是,它是否在以<selector xmlns:android="http://schemas.android.com/apk/res/android">开头的文件(例如)中乱七八糟?

,这就是我拥有的,

代码语言:javascript
复制
<?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>

,这会好得多。

代码语言:javascript
复制
<?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>的文件看起来是正确的(请参阅此消息中的“这会好得多”)。

,不适合我,

代码语言:javascript
复制
<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>

这个布局文件适合我.

代码语言:javascript
复制
<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>
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2013-04-26 13:42:00

你可以试试这个。转到Windows->Preferences-> Android ->Editors,并禁用第一行“使用标准的Android格式化XML文件.”

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/16236189

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档