I am trying to arrange two buttons in an horizontal LinearLayout so that they are evenly distributed, but at the same time the buttons do not stretch over the available space (just has empty space in between).
I am trying to follow what I found in this question, especially the comment from Andrew...
My current layout looks like this.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:background="#ffffff"
android:minHeight="?android:attr/listPreferredItemHeight">
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="horizontal"
>
<Button
android:id="@+id/db_export_cancel"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_gravity="center_horizontal"
android:text="Cancel"
/>
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="horizontal"
>
<Button
android:id="@+id/db_export_ok"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_gravity="center_horizontal"
android:text="OK"
/>
</LinearLayout>
</LinearLayout>
The two LinearLayouts are properly using each half of the available space, but the buttons are aligned to the left in each of them...