2012-11-02 3 views
0
<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:orientation="vertical" > 

    <android.support.v4.view.ViewPager android:id="@+id/groups_of_content" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:layout_weight="0"/> 

    <TextView 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:layout_weight="100" 
     android:text="There are not place for me" /> 

</LinearLayout> 

Dans le code ci-dessus ViewPager occupe tout l'endroit. Comment le faire occuper autant d'espace que le contenu l'exige. En tant que propriété "wrap_content" de la mise en page.faire ViewPager plus petit


UPD: ViewPager est rempli:

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:orientation="horizontal"> 
    <TextView android:id="@+id/group_name" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:text="@string/group_active" 
     /> 
</LinearLayout> 

Je veux ViewPager la taille que Musch comme TextView dans le code ci-dessus. Comment le faire?

Répondre

2

Si vous allez utiliser android: layout_weight vous devez définir l'android: layout_height à 0dip comme dans cet exemple.

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:orientation="vertical" > 

    <android.support.v4.view.ViewPager android:id="@+id/groups_of_content" 
     android:layout_width="fill_parent" 
     android:layout_height="0dip" 
     android:layout_weight="3"/> 

    <TextView 
     android:layout_width="fill_parent" 
     android:layout_height="0dip" 
     android:layout_weight="1" 
     android:text="Must there be place for me" /> 

</LinearLayout> 
+0

Ok, merci. Je mets à jour ma réponse – psct