Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set content in a Linear layout to the BOTTOM of the Screen in Android.?

Tags:

android

See the following XML code

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

    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical" >

        <include layout="@layout/header" />

        <TextView
            android:layout_width="fill_parent"
            android:layout_height="18dp" />

        <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:background="@drawable/header"
            android:orientation="horizontal" >

            <ImageView
                android:layout_width="50dp"
                android:layout_height="50dp"
                android:src="@drawable/calendar" />

            <TextView
                android:id="@+id/tvTitle"
                android:layout_width="fill_parent"
                android:layout_height="50dp"
                android:gravity="center"
                android:text="@string/calendar"
                android:textColor="#FFFFFFFF"
                android:textSize="18sp" />
        </LinearLayout>

        <LinearLayout
            android:id="@+id/myLayout"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical" >


        </LinearLayout>
        <!-- <include layout="@layout/footer"/> -->

        <LinearLayout 
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="bottom"
            android:background="@drawable/datename_bottom_bg"
            android:orientation="horizontal">


            <TextView
                android:id="@+id/upgrade_4"
                android:layout_width="50dp"
                android:layout_height="50dp"
                android:layout_weight="1"
                android:drawableTop="@drawable/upgrade"
                android:gravity="center"
                android:text="@string/upgrade"
                android:textSize="8sp" />

            <TextView
                android:id="@+id/panchang_4"
                android:layout_width="50dp"
                android:layout_height="50dp"
                android:layout_weight="1"
                android:drawableTop="@drawable/kalash_bottom"
                android:gravity="center"
                android:text="@string/panchang"
                android:textSize="8sp" />

            <TextView
                android:id="@+id/time_range_4"
                android:layout_width="50dp"
                android:layout_height="50dp"
                android:layout_weight="1"
                android:drawableTop="@drawable/timer_bottom"
                android:gravity="center"
                android:text="@string/timespan"
                android:textSize="8sp" />

            <TextView
                android:id="@+id/reminder_4"
                android:layout_width="50dp"
                android:layout_height="50dp"
                android:layout_weight="1"
                android:drawableTop="@drawable/reminder_bottom"
                android:gravity="center"
                android:text="@string/reminders"
                android:textSize="8sp" />
            <!--
         <TextView android:id="@+id/calendar_4" android:layout_width="50dp" android:layout_height="50dp" android:drawableTop="@drawable/calendar_bottom"
         android:text="@string/calendar" android:textSize="8sp" android:gravity="center" android:layout_weight="1"/>
            -->
        </LinearLayout >
    </LinearLayout>

</ScrollView>

What this looks like is on the left and what I want it to look like is on the right, I also tried it by replacing LinearLayout to RelativeLaout but still not working. Please Help.! ActualExpected

like image 561
Dnyanesh M Avatar asked Jul 19 '13 09:07

Dnyanesh M


Video Answer


1 Answers

You can include your LinearLayout into a FrameLayout and select in your LinearLayout the attribute android:layout_gravity="bottom":

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

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="bottom">

        <!--Your LinearLayout content-->

    </LinearLayout>

</FrameLayout>
like image 57
amatellanes Avatar answered Sep 28 '22 02:09

amatellanes