Ankit Singh
Ankit Singh

Reputation: 13

Set layout at bottom of screen and rest fill the parent

In my activity there are two LinearLayout,LinearLayout 1 and LinearLayout 2. LinearLayout 2 has to be aligned at the bottom of parent layout and LinearLayout 1 has to take rest of parent height . I have used RelativeLayout and layout_alignParentBottom . It is working but LinearLayout 1 is not taking whole screen , and when i use fill_parent for LinearLayout 1 then it overlaps the LinearLayout 2 .

enter image description here

Upvotes: 1

Views: 832

Answers (1)

Narendra Sorathiya
Narendra Sorathiya

Reputation: 3830

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="0dp"
    android:layout_weight="1"
    android:background="#FF0000"
    android:orientation="vertical"/>

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="100dp"
    android:background="#FFF000"
    android:orientation="vertical"/>

</LinearLayout>

Upvotes: 2

Related Questions