0

I have the following Relative layout which is containing 2 button.

I would like to ask how can i align Relative layout to bottom?

Relative Layout has as a parent Linear layout.

<!-- GROUPED BUTTONS EDIT/CLEAR ALL-->
        <RelativeLayout
            android:id="@+id/group_button_layout_edit_clear"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical"
            android:layout_alignParentBottom="true"
            android:gravity="bottom">

            <LinearLayout
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:gravity="bottom"
                android:orientation="horizontal"
                android:weightSum="2">

                <Button
                    android:id="@+id/group_button_edit"
                    android:layout_width="0dip"
                    android:layout_height="wrap_content"
                    android:layout_alignParentBottom="true"
                    android:layout_alignParentLeft="true"
                    android:layout_weight="1"
                    android:background="@color/grayBg"
                    android:text="@string/clear"
                    android:textColor="@color/colorPrimary"
                    android:textSize="10sp"/>

                <Button
                    android:id="@+id/group_button_clear"
                    android:layout_width="0dip"
                    android:layout_height="wrap_content"
                    android:layout_alignParentBottom="true"
                    android:layout_alignParentRight="true"
                    android:layout_weight="1"
                    android:background="@color/grayBg"
                    android:text="@string/edit"
                    android:textColor="@color/colorPrimary"
                    android:textSize="10sp"/>

            </LinearLayout>
        </RelativeLayout>
        <!-- //GROUPED BUTTONS EDIT/CLEAR ALL-->

Many thanks for any advice.

Viral Patel
  • 32,418
  • 18
  • 82
  • 110
redrom
  • 11,502
  • 31
  • 157
  • 264

1 Answers1

1

In the external LinearLayout add this:

android:orientation="vertical"
android:gravity="bottom"

This will make the contained RelativeLayout move to the bottom.

Viral Patel
  • 32,418
  • 18
  • 82
  • 110
  • Thanks but this moves all content in parent LinearLayout to bottom. I move bottom only the Relative layout. I tried to add android:layout_gravity="top" to Layout which should to have top position, but it does not works. – redrom Jan 21 '16 at 17:42
  • then seperate out the relative layout in a seperate linear layout and set gravity botttom for that layout. keep all other views on the other linear layout. – Viral Patel Jan 21 '16 at 17:44
  • Problem is that button and other content should be in the parent linearLayout (because it presents left column). – redrom Jan 21 '16 at 17:47
  • 1
    yes, keep them in the parent layout just wrap them with another linear layout and wrap the relative layout with another linear layout inside parent linear layout. – Viral Patel Jan 21 '16 at 17:48
  • Thank You, it is not optimal solution (wrapping layout into other layout) but it works. – redrom Jan 21 '16 at 17:56
  • yes, it is not optimal, but the nature of your existing layout was such. You can change the root layout to relative and position the contained views as you want. That would be more optimal but slightly tricky. – Viral Patel Jan 21 '16 at 17:57