I have two different LinearLayouts inside one LinearLayout and I would like the first layout to be at the top and the second layout to be at the bottom. I tried with android:gravity="top" but it didn’t work. Here is my xml code:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="fill_parent"
android:layout_height="fill_parent" android:gravity="center">
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:gravity="top">
<ImageView android:layout_height="wrap_content" android:id="@+id/imageView1"
android:src="@drawable/icon" android:layout_width="wrap_content"></ImageView>
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:layout_height="wrap_content">
<TableRow android:weightSum="2">
<Button android:text="Button" android:id="@+id/button2"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:layout_weight="1"></Button>
<Button android:text="Button" android:id="@+id/button1"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:layout_weight="1"></Button>
</TableRow>
<TableRow android:weightSum="2">
<Button android:text="Button" android:id="@+id/button3"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:layout_weight="1"></Button>
<Button android:text="Button" android:id="@+id/button4"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:layout_weight="1"></Button>
</TableRow>
</TableLayout>
</LinearLayout>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:gravity="bottom">
<ImageView android:layout_height="wrap_content" android:id="@+id/imageView1"
android:src="@drawable/icon" android:layout_width="wrap_content"></ImageView>
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:layout_height="wrap_content">
<TableRow android:weightSum="2">
<Button android:text="Button" android:id="@+id/button2"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:layout_weight="1"></Button>
<Button android:text="Button" android:id="@+id/button1"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:layout_weight="1"></Button>
</TableRow>
<TableRow android:weightSum="2">
<Button android:text="Button" android:id="@+id/button3"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:layout_weight="1"></Button>
<Button android:text="Button" android:id="@+id/button4"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:layout_weight="1"></Button>
</TableRow>
</TableLayout>
</LinearLayout>
You could simply add :
between your top and bottom
LinearLayout(and remove the gravity from the parent container).