2010-11-14 5 views
1

Je travaille sur une application qui affiche des informations sur les pays du monde (j'apprends quelque chose de réel et j'ai déjà ces données). Une partie de ma mise en page est un LinearLayout qui contient le drapeau du pays et quelques informations de base. Il y a cinq rangées d'informations dans le tableau à droite du drapeau. Le problème est que LinearLayout n'utilise que la hauteur du drapeau pour sa hauteur totale. La plupart des drapeaux ont une hauteur de 2,5 lignes et certaines de mes informations sont coupées. Pourquoi la hauteur de LiniearLayout n'est-elle pas le plus grand de ses deux éléments? Des suggestions pour ce que je peux faire pour que cela fonctionne?Pourquoi mon LinearLayout horizontal ne réserve-t-il pas assez de hauteur pour son contenu?

Voici la définition du LinearLayout en question:

 <LinearLayout 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:orientation="horizontal"> 
     <ImageView 
      android:id="@+id/flag" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:adjustViewBounds="true" 
      android:src="@drawable/noflag" /> 
     <TableLayout 
      android:id="@+id/info1" 
      android:layout_width="wrap_content" 
      android:layout_height="fill_parent" 
      android:layout_marginLeft="10dip"> 
      <TableRow> 
       <TextView 
        android:id="@+id/capitallabel" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:text="@string/capital_label" 
        style="?infoLabel"/> 
       <TextView 
        android:id="@+id/capitalvalue" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:layout_marginLeft="4dip" 
        style="?infoValue"/> 
      </TableRow> 
      <TableRow> 
       <TextView 
        android:id="@+id/capitaltimelabel" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:text="@string/capital_time_label" 
        style="?infoLabel"/> 
       <TextView 
        android:id="@+id/capitaltimevalue" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:layout_marginLeft="4dip" 
        style="?infoValue"/> 
      </TableRow> 
      <TableRow> 
       <TextView 
        android:id="@+id/landarealabel" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:text="@string/land_area_label" 
        style="?infoLabel"/> 
       <TextView 
        android:id="@+id/landareavalue" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:layout_marginLeft="4dip" 
        style="?infoValue"/> 
      </TableRow> 
      <TableRow> 
       <TextView 
        android:id="@+id/waterarealabel" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:text="@string/water_area_label" 
        style="?infoLabel"/> 
       <TextView 
        android:id="@+id/waterareavalue" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:layout_marginLeft="4dip" 
        style="?infoValue"/> 
      </TableRow> 
      <TableRow> 
       <TextView 
        android:id="@+id/coastlinelabel" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:text="@string/coast_line_label" 
        style="?infoLabel"/> 
       <TextView 
        android:id="@+id/coastlinevalue" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:layout_marginLeft="4dip" 
        style="?infoValue"/> 
      </TableRow> 
     </TableLayout> 
    </LinearLayout> 

J'ai essayé renverser la table et l'affichage de l'image de sorte que le drapeau était à droite et les informations sur la gauche. J'espérais que la hauteur de LiniearLayout serait maintenant la hauteur de la table d'information. Pas de chance, c'était toujours la hauteur du drapeau.

Toute aide serait appréciée.

Merci,

Ian

Répondre

1

Essayez android:layout_height="wrap_content" pour votre TableLayout.

+0

Oh homme recrue erreur - qui l'a parfaitement corrigé. –

Questions connexes