0

ctrl+ shift+を押して Eclipse Helios でコードをフォーマットしようとするとf、コードはフォーマットされますが、結果は非常に見苦しくなります。たとえば、1 行に 2 つまたは 3 つのステートメントを記述します。インデントも非常に悪いです。

例: コードをフォーマットすると、次のようになります。

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
 android:orientation="vertical" android:layout_width="fill_parent"
 android:layout_height="fill_parent" android:background="@drawable/scannerbg">

 <include android:id="@+id/headerLayout"
  android:layout_alignParentTop="true" layout="@layout/headerlayout" />

 <ListView android:layout_below="@id/headerLayout"
  android:layout_height="fill_parent" android:layout_marginTop="5dp"
  android:listSelector="@android:color/transparent" android:id="@+id/listView"
  android:layout_width="fill_parent">
 </ListView>

</RelativeLayout>

でわかるようにListView、1 行に 2 ~ 3 個のステートメントがあります。

誰でもこれに対する解決策を提供できますか?

4

2 に答える 2

2

Eclipse で、 [ウィンドウ] メニューから [設定] を選択します。Androidノードを展開し、 Editorsサブノードを選択します。右側のペインで、「標準の Android XML スタイルを使用して XML ファイルをフォーマットする..」(最初のオプション) がチェックされていることを確認します。

Ctrl+ Shift+fおよび/またはCtrl+iは期待どおりに動作し、次の結果が得られるはずです。

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="@drawable/scannerbg"
    android:orientation="vertical" >

    <include
        android:id="@+id/headerLayout"
        android:layout_alignParentTop="true"
        layout="@layout/headerlayout" />

    <ListView
        android:id="@+id/listView"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_below="@id/headerLayout"
        android:layout_marginTop="5dp"
        android:listSelector="@android:color/transparent" >
    </ListView>

</RelativeLayout> 
于 2012-08-29T10:52:30.853 に答える
1

完全な書式設定を行うには、ADT バージョン 20 を使用してください。

于 2012-08-29T19:02:11.900 に答える