I’ve been trying to arrange my cells in my table row below such that the second cell’s value (a Button with a background image) is right up next to the right of the text from the first cell. The below currently stretches the image in cell 2 and looks like
.
Any ideas on how to stop the stretching and position the button image in the far left of cell 2?
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TableLayout
android:layout_width="fill_parent"
android:layout_weight="1"
android:layout_height="wrap_content"
android:stretchColumns="1"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp">
<TableRow>
<TextView
android:id="@+id/timeMainLabel"
android:layout_weight="1"
android:textSize="14sp"
android:layout_column="0"
android:padding="1dip"
android:text="cell one texxxxxxxxt"/>
<Button
android:id="@+id/pdm_tooltip_btn1"
android:layout_column="1"
android:background="@drawable/tooltip_btn" />
<TextView
android:layout_column="2"
android:id="@+id/timeLabel"
android:textSize="14sp"
android:text="cell 3"
android:gravity="right"
android:padding="1dip"
android:visibility="visible"
android:layout_weight="1"/>
</TableRow>
<TableRow>
<TextView
android:id="@+id/timeMainLabel"
android:layout_weight="1"
android:textSize="14sp"
android:layout_column="0"
android:padding="1dip"
android:text="cell one text"/>
<Button
android:id="@+id/pdm_tooltip_btn1"
android:layout_column="1"
android:background="@drawable/tooltip_btn" />
<TextView
android:layout_column="2"
android:id="@+id/timeLabel"
android:textSize="14sp"
android:text="cell 3"
android:gravity="right"
android:padding="1dip"
android:visibility="visible"
android:layout_weight="1"/>
</TableRow>
</TableLayout>
</LinearLayout>
Updated Image:

It’s gonna require some fiddling around. Basically, you will have to add some empty column after column 1 (that would be the second column since they are zero indexed).
So you will have:
Now you can fiddle with
weightif you fancy and set it up accordingly.The third column (column 2) will fill the space between the two elements so have it stretch if needed.