5

I have a layout like the following:

<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".SettingsActivity" >

<TableRow
    ...
</TableRow>

<TableRow
    ...
</TableRow>

<TableRow
    android:id="@+id/tableRow3"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
 >
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Temperature:" />

        <SeekBar
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" />
</TableRow>

In the third TableRow the TextView and the SeekBar share the space equally. I want the TextView to be only as wide is the text inside it, and the SeekBar should fill the rest of the space. I have tried fiddling with gravity, width, and weights. What is the best way to get this behavior?

Jutanium
  • 421
  • 3
  • 16
  • Change the weights of row in java depending on lenghth of edittext in event of keypress – Charlie Jul 31 '13 at 01:29
  • It isn't an EditText. It's an uneditable text box. – Jutanium Jul 31 '13 at 01:30
  • 6
    Use `android:stretchColumns="1"` on the `TableLayout`. This would however make all the views from the second column take as much space as needed. If you don't want this then `TableLayout` is not the way to go. – user Jul 31 '13 at 04:15
  • Thanks. I switched to a RelativeLayout. – Jutanium Jul 31 '13 at 15:55

0 Answers0