What is wrong with this code? Why doesn’t the button go right in this table row?
<TableLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
>
<TableRow>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/str1"
/>
<EditText
android:id="@+id/id1"
android:layout_width="70dp"
android:layout_height="wrap_content"
/>
<Button
android:id="@+id/id2"
android:layout_width="wrap_content"
android:layout_height="65dp"
android:text="@string/str2"
android:gravity="right"/>
</TableRow>
</TableLayout>
You should either use android:stretchColumns=”1″ in your TableLayout, so that your EditText pushes your Button to the right.
Or you can use android:layout_weight attribute on the views in a tableRow to distribute the space accordingly.
Also, you dont need to specify width and height attributes on the views in a TableRow.