views:

602

answers:

1

I am trying to have a tablelayout contains several tablerows. One of the rows contains 4 buttons, while the second row contains a very long text. However, the width of the button stretches with the text in the second row. Is there anyway to prevent this?

alt text alt text

http://img684.imageshack.us/i/tableview1.jpg/

http://img521.imageshack.us/i/tableview2.jpg/

Here is my xml file: (somehow this website is not friendly to xml file)

AbsoluteLayout android:id="@+id/widget0" android:layout_width="fill_parent" android:layout_height="fill_parent" xmlns:android="http://schemas.android.com/apk/res/android" >

TableLayout android:id="@+id/widget28" android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="vertical" android:layout_x="0px" android:layout_y="10px" >

TableRow android:id="@+id/widget29" android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="horizontal" >

Button android:id="@+id/widget30" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Button" >

Button android:id="@+id/widget31" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Button" >

Button android:id="@+id/widget32" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Button" >

Button android:id="@+id/widget33" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Button" >

TableRow android:id="@+id/widget35" android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="horizontal" >

TextView android:id="@+id/widget40" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="TextViewTextViewTextViewTextViewTextViewTextView" >

+1  A: 

try using android:layout_span="4" for TextView

Replace 4 by whatever be the number of columns(buttons) in first row is..

Also, you can leave out android:layout_width and layout_height parameters from the Tablerow

Anshul
It didn't work out. The text strentched ouside the screen, the first button is still that big.I am starting to wondering if it is a bug of android?
Yang
It works for me, here is the working XML for 2nd row from my side (probably you put layout_span attribute at wrong place):<TableRow android:id="@+id/widget35" android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="horizontal" ><TextView android:id="@+id/widget40" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_span="4" android:text="TextViewTextViewTextViewTextViewTextView" /> </TableRow>Also, you can easily omit: layout_width="wrap_content" layout_height="wrap_content"from the Button and other tablerow tags.
Anshul
Also, why are you using an AbsoluteLayout, i would not recommend using it unless its absolute necessity.
Anshul
Thanks...it is still not working for me though. I have give up and used a separate Linearlayout for these buttons.
Yang