views:

1994

answers:

2

I want to build the following layout but it is not working.

alt text

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

This seems correct. But you probably have to play with the android:layout_width and android:layout_height parameters.

Maybe you should show us your whole layout ?

dystroy
+5  A: 

I put this together really fast, try this:

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>
Jeffrey
Ideally the width of the imageviews should be wrap_content, and the width of the tablelayout, 0dip. Then add a layout_weight of 1.0 to the tablelayout.
Romain Guy