2012-07-12 4 views
0

Je souhaite utiliser un seul fragment deux fois en mode paysage et une fois en mode portrait.Utilisation efficace des fragments dans Android

Le xml pour le mode paysage:

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

Comment puis-je concevoir la vue en mode portrait?

Répondre

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>