Android中碎片的有效使用

Android中碎片的有效使用,android,android-layout,android-fragments,Android,Android Layout,Android Fragments,我想在横向模式下使用两次单个片段,在纵向模式下使用一次 用于横向模式的xml: <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/linearLayout1" android:layout_width="fill_parent" android:layout_height="fill_parent" android:backg

我想在横向模式下使用两次单个片段,在纵向模式下使用一次

用于横向模式的xml:

  <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/linearLayout1"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="#ffffff" android:orientation="horizontal" >
  <fragment class="com.afghanmag.android.StoreViewFragment"
        android:id="@+id/categories" android:layout_weight="1"
        android:layout_width="0px"
        android:layout_height="match_parent" />

  <fragment class="com.afghanmag.android.StoreViewFragment"
        android:id="@+id/library" android:layout_weight="1"
        android:layout_width="0px"
        android:layout_height="match_parent" />
  </LinearLayout>

如何设计纵向模式视图?


<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/relativeLayout1"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="#ffffff">

    <fragment class="com.afghanmag.android.StoreViewFragment"
        android:id="@+id/categories"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:layout_alignParentLeft="true"
        android:layout_centerVertical="true"/>

</RelativeLayout>