2010-02-03 26 views
18

Aşağıdaki düzeni oluşturmak istiyorum ama çalışmıyor.android table layout rowspan

<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

ben [bu gerçekten güzel buldum tuto tableLayout'ta rial] (http://coderzheaven.com/index.php/2011/03/android-tablelayout/). – Max

cevap

33
Gerçekten çok hızlı bunları yapan

alt text http://toms-toy.de/rowspan.gif, şunu deneyin:

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

İdeal olarak, görüntü görüntülerinin genişliği wrap_content ve tablelayout'un genişliği olan 0dip olmalıdır. Ardından, tablo düzeni için bir layout_weight 1.0 ekleyin. –

+0

Sadece bunun için Jeffrey'e teşekkür etmek istedim, saçlarımı anlamaya çalışıyorum ve herkesin bildiği gibi, yönelim = "yatay" çok önemli! En iyisi Mike – Mike

7

denemek bu:

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