Reputation: 384
I am using a table layout in my android
application.
I have "Button EditText Button" that shall fill a row. The two buttons shall only take what they need to display their respective button text, anything else should be taken by EditText.
For reasons I don't manage to google, the first button takes the full line width. Anyone knows why?
My .xml file looks like this:
<?xml version="1.0" encoding="utf-8"?>
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/tableLayout1"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<TableRow
android:id="@+id/primaryControls"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="10dip" >
<Button
android:id="@+id/radicalClearButton"
android:text="@string/radicalClearButton" />
<EditText
android:id="@+id/radical"
android:hint="@string/radical_input" >
</EditText>
<Button
android:id="@+id/radicalGoButton"
android:text="@string/radicalGoButton" />
</TableRow>
<TableRow
android:id="@+id/separatorRow1"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<View
android:id="@+id/radicalView_separator"
android:layout_width="wrap_content"
android:layout_height="1dp"
android:layout_marginBottom="10dp"
android:layout_marginTop="15dp"
android:background="#000000" />
</TableRow>
Upvotes: 0
Views: 388
Reputation: 1073
You can use something like this.
<?xml version="1.0" encoding="utf-8"?>
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/tableLayout1"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<TableRow
android:id="@+id/primaryControls"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:padding="10dip"
android:weightSum="3" >
<Button
android:id="@+id/radicalClearButton"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/radicalClearButton" />
<EditText
android:id="@+id/radical"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:hint="@string/radical_input" >
</EditText>
<Button
android:id="@+id/radicalGoButton"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/radicalGoButton" />
</TableRow>
<TableRow
android:id="@+id/separatorRow1"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<View
android:id="@+id/radicalView_separator"
android:layout_width="wrap_content"
android:layout_height="1dp"
android:layout_marginBottom="10dp"
android:layout_marginTop="15dp"
android:background="#000000" />
</TableRow>
Upvotes: 1