2012-07-12 66 views
0

我想在橫向模式下使用單個片段兩次,在縱向模式下使用一次。在Android中有效使用片段

爲橫向模式的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> 

我怎樣才能設計出肖像模式的看法?

回答

0
<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>