Search code examples
androidandroid-layoutandroid-relativelayout

Using RelativeLayout to make a View take all remaining space


I want to achieve this

required

I am doing this

<RelativeLayout
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">
    <LinearLayout
        android:id="@+id/upper"
        android:orientation="horizontal"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:background="@color/wallet_dim_foreground_inverse_disabled_holo_dark">
    </LinearLayout>
    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="80dp"
        android:orientation="horizontal"
        android:layout_below="@+id/upper"
        android:background="@color/blueAccentColor">
    </LinearLayout>
</RelativeLayout>

Solution

  • <RelativeLayout
        android:layout_width="fill_parent"
        android:layout_height="fill_parent">
        <LinearLayout
            android:id="@+id/upper"
            android:orientation="horizontal"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:layout_above="@+id/lower"
            android:background="@color/wallet_dim_foreground_inverse_disabled_holo_dark">
            </LinearLayout>
        <LinearLayout
            android:id="@+id/lower"
            android:layout_width="fill_parent"
            android:layout_height="80dp"
            android:orientation="horizontal"
            android:layout_alignParentBottom="true"
            android:background="@color/blueAccentColor"></LinearLayout>
        </RelativeLayout>