0

私はフラグメントを含む 2 つのレイアウトを使用しています。1 つはポートレート モード用で、もう 1 つはランドスケープ用です。両方のレイアウトにスティッキー フッターを追加する必要があり、ポートレート レイアウトには正常に追加されましたが、ランドスケープ レイアウトに同様のコードを使用すると機能しません。layout_widthフラグメントの をに設定すると0dp、どちらのフラグメントも表示されません。layout_widthwrap_contentまたはに設定するfill_parentと、フラグメントは互いにオーバーラップします。

これは私がこれまでに持っているものです:

<?xml version="1.0" encoding="utf-8"?>

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="horizontal"
    android:layout_height="fill_parent"
    android:layout_width="fill_parent"
>
    <!-- Footer -->     
    <TextView 
            android:id="@+id/footer" 
            android:layout_width="fill_parent" 
            android:layout_height="wrap_content" 
            android:layout_alignParentBottom="true"
     />
    <!-- Footer -->

    <fragment android:name="com.app.listing1"
            android:id="@+id/fragment1"
            android:layout_width="wrap_content"
            android:layout_height="fill_parent"
            android:layout_above="@id/footer"            
     />

    <fragment android:name="com.app.listing2"
            android:id="@+id/fragment2"
            android:layout_width="wrap_content"
            android:layout_height="fill_parent"
            android:layout_above="@id/footer"            
     />

</RelativeLayout>

編集

なりたい自分に少し近づいた。fragment1 に幅を設定すると、探しているものが得られますが、それは明らかに理想的ではありません。何らかの理由で、両方のフラグメントのレイアウトと各フラグメント内のレイアウトで layout_width="wrap_content" を設定すると、最初のフラグメントが画面全体を占有する結果になります。

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="horizontal"
    android:layout_height="fill_parent"
    android:layout_width="fill_parent"
>
    <!-- Footer -->     
    <TextView 
            android:id="@+id/footer" 
            android:layout_width="fill_parent" 
            android:layout_height="wrap_content" 
            android:layout_alignParentBottom="true"
     />
    <!-- Footer -->

    <fragment android:name="com.app.listing1"
            android:id="@+id/fragment1"
            android:layout_width="200dp"
            android:layout_height="fill_parent"
            android:layout_above="@id/footer"            
            android:layout_toLeftOf="@id/fragment2"
     />

    <fragment android:name="com.app.listing2"
            android:id="@+id/fragment2"
            android:layout_width="wrap_content"
            android:layout_height="fill_parent"
            android:layout_above="@id/footer"            
            android:layout_toRightOf="@id/fragment1"
     />

</RelativeLayout>
4

1 に答える 1

0

編集:

RelativeLayout で配置しなかったため、フラグメントが互いに重なり合っています。それらを水平に配置する場合はlayout_toRightOf、またはを使用しますlayout_toLeftOf

于 2012-04-07T19:40:51.693 に答える