2010-02-03 2 views
18

다음 레이아웃을 만들고 싶지만 작동하지 않습니다.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

내가 [이 정말 좋은 발견 투투 rial on tableLayout] (http://coderzheaven.com/index.php/2011/03/android-tablelayout/)을 참조하십시오. – Max

답변

33
정말 빨리 이것을 함께 넣어

alt text http://toms-toy.de/rowspan.gif,이 시도 :

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

이상적으로 이미지 뷰의 너비는 wrap_content 여야하며 테이블 레이아웃의 너비 인 0dip이어야합니다. 그런 다음 tablelayout에 layout_weight 1.0을 추가합니다. –

+0

제프리에게 감사 드리고 싶습니다. 머리카락을 꺼내려고 노력하고 있습니다. 모두가 알고있는 것처럼 방향 = "수평"이 매우 중요합니다! 최고, Mike – Mike

7

이 시도이 :

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