views:

1602

answers:

1

(Edited: I'm one step further than before)

I've been trying to get a simple 2-column TableLayout going where I have a LinearLayout in my left column that I dynamically add elements to which fills up the horizontal space except for the fixed 100px right column.

Here's what I have so far which works for me IF the LinearLayout contains more than one element. If it contains only one element, the right column is pushed out to the right of the screen

 <ScrollView android:layout_width="fill_parent"
             android:layout_height="fill_parent"
             xmlns:android="http://schemas.android.com/apk/res/android"
             android:id="@layout/main">
  <TableLayout android:layout_width="fill_parent"
               android:layout_height="fill_parent">
     <TableRow>
       <LinearLayout android:id="@+id/LinearLayout01"
                         android:layout_width="fill_parent"
                         android:layout_height="fill_parent" 
                         android:layout_weight="0.4"
                         android:orientation="vertical"></LinearLayout>
    <com.epaga.ArcDrawableView 
                         android:layout_width="fill_parent" 
                         android:layout_height="fill_parent" 
                         android:gravity="right" android:layout_weight="0.1" >
       </com.epaga.ArcDrawableView>
     </TableRow>
   </TableLayout>
 </ScrollView>

Things I've tried:

  • changing the drawable view (which is supposed to be the fixed column) to android:layout_width="150px"
  • changing the stretchcolumns setting to 0.
  • changing the left columns' layout_width to either fill_parent (pushes the right column off the screen) or wrap_content (collapses the left column)

Any thoughts?

+2  A: 

Any thoughts?

First, why are you using a TableLayout? Why not just use nested LinearLayouts? You've already decided you don't care about the primary use for a TableLayout -- automatic computation of column sizes -- because you're trying to fix the column sizes yourself.

Second, can you get it working using an ordinary widget for the right column, rather than your custom View class? Your problem may be due to your custom View -- I'd start by getting something working the way you want using ordinary widgets.

CommonsWare
hah! thanks, the nested LinearLayouts worked. I didn't do the horizontal LinearLayout because I assumed it would push the elements offscreen, but when I set layout_width to fill_parent, it works great. i assumed it was going to be something d'uh like that.
Epaga