Atrus
Atrus

Reputation: 798

Why does the RelativeView not go to the bottom?

Specifically I'm trying to get the RelativeLayout with the id bottomStuff to float down towards the bottom. I tried setting the gravity setting to bottom, which has been suggested from other SO posts, but it still sticks all the way at the top, why is this?

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
android:id="@+id/relativeLayout1" android:layout_width="fill_parent"
android:layout_height="fill_parent" android:gravity="center">

<TextView android:id="@+id/textView1" android:textAppearance="?android:attr/textAppearanceLarge"
    android:layout_alignParentRight="true" android:layout_weight="1"
    android:layout_width="fill_parent" android:layout_height="wrap_content"
    android:text="@string/currentAlarms" android:gravity="center"
    android:layout_alignParentTop="true">
</TextView>

<ScrollView android:id="@+id/scroll" android:layout_width="fill_parent"
    android:layout_below="@+id/textView1" android:layout_centerVertical="true"
    android:gravity="center" android:layout_height="wrap_content"
    android:layout_marginBottom="150px">

    <LinearLayout android:layout_width="wrap_content"
        android:id="@+id/alarms" android:orientation="vertical"
        android:gravity="center" android:layout_centerVertical="true"
        android:layout_height="wrap_content">
    </LinearLayout>
</ScrollView>

<RelativeLayout android:id="@+id/bottomStuff"
android:layout_height="wrap_content" android:layout_width="fill_parent"
    android:layout_alignParentBottom="true"
    android:layout_centerHorizontal="true" android:layout_marginBottom="12dp"
    android:gravity="bottom">

<com.google.ads.AdView android:id="@+id/adView"
                     android:layout_width="wrap_content"
                     android:layout_height="wrap_content"
                     ads:adUnitId="a14e1a859cbb3fb"
                     ads:adSize="BANNER"
                     ads:loadAdOnCreate="true"/>

        <LinearLayout android:id="@+id/BLinearLayout"
        android:layout_height="wrap_content" android:layout_width="fill_parent"
        android:layout_below="@+id/adView"
        android:layout_alignParentBottom="true"
        android:layout_centerHorizontal="true"
        android:gravity="bottom">

        <Button android:layout_height="wrap_content" android:text="@string/addAlarm"
            android:id="@+id/button1" android:layout_width="0px"
            android:layout_weight="1" android:drawableTop="@drawable/plus"
            android:onClick="addAlarm">
        </Button>
        <Button android:layout_width="0px" android:layout_height="wrap_content"
            android:id="@+id/button2" android:layout_centerVertical="true"
            android:layout_alignParentRight="true" android:layout_weight="1"
            android:text="@string/settings" android:drawableTop="@drawable/preferences">
        </Button>

    </LinearLayout>
</RelativeLayout>

</RelativeLayout>

Thanks!

Upvotes: 1

Views: 125

Answers (3)

Zarah
Zarah

Reputation: 5189

In your LinearLayout with the Buttons, remove the layout_alignParentBottom:

<LinearLayout android:id="@+id/BLinearLayout"
        android:layout_height="wrap_content" android:layout_width="fill_parent"
        android:layout_below="@+id/adView"
        android:layout_centerHorizontal="true"
        android:layout_gravity="bottom">

Upvotes: 2

Nicklas A.
Nicklas A.

Reputation: 7061

Your XML is messed up, I see two open tags for a RelativeLayout but only one close tag, have you tried doing a clean? That should generate an error

Upvotes: 0

Lior Ohana
Lior Ohana

Reputation: 3527

Try changing the layout_gravity to gravity.

Upvotes: 0

Related Questions