0

現在、Scrollview に埋め込まれた RelativeLayout を作成しようとしています (したがって、RelativeLlayout のコンテンツを垂直方向にスクロールできます)。私のレイアウトファイルは次のようになります。

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" >

    <RelativeLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content" >

        <TextView
            android:id="@+id/label_first_day_of_budget_cycle"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:layout_alignParentLeft="true"
            android:layout_alignParentTop="true"
            android:layout_margin="10dp"
            android:text="@string/first_day_of_budget_cycle"
            android:textSize="20sp" />

        <include
            android:id="@+id/settings_divider_one"
            android:layout_alignParentLeft="true"
            android:layout_below="@id/label_first_day_of_budget_cycle"
            layout="@layout/w_divider" />

        <TextView
            android:id="@+id/label_monthly_income"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:layout_alignParentLeft="true"
            android:layout_below="@id/settings_divider_one"
            android:layout_margin="10dp"
            android:text="@string/monthly_income"
            android:textSize="20sp" />

        <include
            android:id="@+id/settings_add_income"
            android:layout_alignParentLeft="true"
            android:layout_below="@id/label_monthly_income"
            layout="@layout/w_add" />

        <include
            android:id="@+id/settings_divider_two"
            android:layout_alignParentLeft="true"
            android:layout_below="@id/settings_add_income"
            layout="@layout/w_divider" />

        <TextView
            android:id="@+id/label_monthly_expenses"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:layout_alignParentLeft="true"
            android:layout_below="@id/settings_divider_two"
            android:layout_margin="10dp"
            android:text="@string/monthly_expenses"
            android:textSize="20sp" />

        <include
            android:id="@+id/settings_add_expenses"
            android:layout_alignParentLeft="true"
            android:layout_below="@id/label_monthly_expenses"
            layout="@layout/w_add" />

        <include
            android:layout_alignParentLeft="true"
            android:layout_below="@id/settings_add_expenses"
            layout="@layout/w_divider" />
    </RelativeLayout>

</ScrollView>

そして、これは私の電話でどのように見えるかです:

ここに画像の説明を入力

ネットやスタックオーバーフローで考えられる/見つけることができるすべてのバリエーションを試しましたが、これまでのところ成功していません。他に何を試すことができるのか、ここで何が欠けているのかわかりません。

RelativeLayout と Scrollview の layout_width と layout_height の値を変えてみましたが、成功しませんでした。私が間違っていることについてのヒントは大歓迎です。

アップデート

ベンの提案に従って、インクルードを削除し、レイアウトを適切にレンダリングしました。私は、Scrollviews に埋め込まれた RelativeLayouts をインクルードする必要があると考えているので、バグ レポートクリックを提出しました。少なくとも、そうすべきではない理由がわかりません。インクルードが適切に機能しない別の間違いがレイアウトに含まれている場合は、チケットでそれに応じて返信されることを願っています。

4

2 に答える 2

0

の代わりにLinearLayout幅と高さのある を使用してみてください。fill_parentRelativeLayout

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent" android:layout_height="fill_parent" >
    <LinearLayout android:orientation="vertical"
            android:layout_width="fill_parent" android:layout_height="fill_parent" >
          ... your content here

要素を垂直方向に配置するために使用RelativeLayoutするのは悪い考えです (パフォーマンスが低下し、読みにくくなります)。相対的なレイアウトが本当に必要な場合は、LinearLayout 要素内に追加できます。幅と高さが であることを確認してくださいfill_parent

于 2013-01-03T21:57:29.567 に答える