Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Align fragment on bottom of screen

Hi I have a linear layout with a fragment widget placed inside it. I'm trying get the fragment to show up on the bottom of the screen. The page may be scrollable in the future so I want it anchored on the bottom of the screen always. How can I achieve this?

like image 854
n3wb Avatar asked Aug 12 '13 16:08

n3wb


1 Answers

You must use RelativeLayout. Something like this:

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

    <ScrollView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_above="@+id/bottom_fragment" >
    </ScrollView>

    <fragment
        android:id="@+id/bottom_fragment"
        android:layout_width="match_parent"
        android:layout_height="100dp"
        android:layout_alignParentBottom="true" >
    </fragment>

</RelativeLayout>
like image 120
zella Avatar answered Nov 08 '22 21:11

zella