2010-02-03 4 views
18

Je souhaite créer la mise en page suivante, mais cela ne fonctionne pas.android table layout rowspan

alt text http://toms-toy.de/rowspan.gif

<LinearLayout android:orientation="horizontal"...> 
    <ImageView ...></ImageView> 
     <TableLayout ...> 
         <TableRow..> 
           <ImageView ...></ImageView> 
           <ImageView ...></ImageView> 
           <ImageView ...></ImageView> 
         </TableRow> 
         <TableRow..> 
           <ImageView ...></ImageView> 
           <ImageView ...></ImageView> 
           <ImageView ...></ImageView> 
         </TableRow> 
     </TableLayout> 
    <ImageView ...></ImageView> 
</LinearLayout> 
+0

J'ai trouvé [ce vraiment sympa tuto rial sur tableLayout] (http://coderzheaven.com/index.php/2011/03/android-tablelayout/). – Max

Répondre

33

Je mets cela ensemble très vite, essayez ceci:

alt text

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:orientation="horizontal" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent"> 
    <ImageView android:layout_width="50dip" android:layout_height="100dip" android:background="#cc0000"/> 
    <TableLayout android:layout_width="wrap_content" android:layout_height="wrap_content"> 
     <TableRow> 
      <ImageView android:layout_width="50dip" android:layout_height="50dip" android:background="#aaaa00"/> 
      <ImageView android:layout_width="50dip" android:layout_height="50dip" android:background="#00aa00"/> 
      <ImageView android:layout_width="50dip" android:layout_height="50dip" android:background="#aaaa00"/> 
     </TableRow> 
     <TableRow> 
      <ImageView android:layout_width="50dip" android:layout_height="50dip" android:background="#00aa00"/> 
      <ImageView android:layout_width="50dip" android:layout_height="50dip" android:background="#aaaa00"/> 
      <ImageView android:layout_width="50dip" android:layout_height="50dip" android:background="#00aa00"/> 
     </TableRow> 
    </TableLayout> 
    <ImageView android:layout_width="50dip" android:layout_height="100dip" android:background="#cc0000"/> 
</LinearLayout> 
+3

Idéalement, la largeur des images doit être wrap_content, et la largeur du tablelayout, 0dip. Puis ajoutez un layout_weight de 1.0 au tablelayout. –

+0

Je voulais juste remercier Jeffrey pour ça, je me suis arraché les cheveux en essayant de comprendre cela et juste pour que tout le monde le sache, l'orientation = "horizontale" est très importante! Meilleur, Mike – Mike

7

essayer ceci:

<TableLayout 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content"> 
    <TableRow> 
     <TextView android:text="1-2, 1;\t" android:layout_gravity="center" /> 
     <TableLayout> 
      <TableRow> 
       <TextView android:text="1, 2;\t" android:layout_gravity="center" /> 
      </TableRow> 
      <TableRow> 
       <TextView android:text="2, 2;\t" android:layout_gravity="center" /> 
      </TableRow> 
     </TableLayout> 
    </TableRow> 
</TableLayout>