I want to create a layout for four image button. With two buttons in a row, so that it looks like a cube in the layout. Because I want to support API Level 8 i cannot use grid layout, so I tried it with a combination of LinearLayout.
A root LinearLayout with horizontal orientation, this contains two linearlayout with vertical orientation. These contain my buttons, but i does not work as expected, only one row with two buttons is visible. Can someone help me, thanks
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/action_screen"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal"
android:paddingTop="30px">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal" >
<ImageButton
android:id="@+id/btn_start_cam"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:onClick="startCamAction"
android:src="@drawable/photo_button" />
<ImageButton
android:id="@+id/btn_photo_lib"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:onClick="startPhotoLibAction"
android:src="@drawable/library_blau" />
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal" >
<ImageButton
android:id="@+id/btn_start_barcode"
android:onClick="startBarcodeAction"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/barcode_blau" />
<ImageButton
android:id="@+id/btn_start_qr_barcode"
android:onClick="startQRcodeAction"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/qr_code_blau" />
</LinearLayout>
</LinearLayout>
Set the height of the two child LinearLayouts to wrap_content. Otherwise the first LinearLayout will take up the whole height of the parent layout.