Problems with <include> on a Relative Layout, views always at Top

android, android-relativelayout, include

Solution

`<include />` is really just cut & paste and `<merge />` means join the RelativeLayout. So you need to give these elements RelativeLayout rules, try adding:

android:layout_above="@+id/button_container"

To the divider View. And add:

android:layout_alignParentBottom="true"

To the LinearLayout.

Problem

I have a few layouts where I want to `inlcude/>` a bottom bar that contains two buttons. Pretty simple huh? Well, I am having issues getting this acomplished as the buttons are being set to the top of the View regardless of the parameters I set for it. Here's how it currently looks. Here's the actual merge code: ``` <?xml version="1.0" encoding="utf-8"?> <merge xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="vertical" > <View android:id="@+id/divider" android:layout_width="match_parent" android:layout_height="1dp" android:background="?android:attr/dividerHorizontal" /> <LinearLayout android:id="@+id/button_container" android:layout_width="match_parent" android:layout_height="wrap_content" android:divider="?android:attr/dividerVertical" android:orientation="horizontal" android:showDividers="middle" > <Button android:id="@+id/left_button" style="?android:attr/borderlessButtonStyle" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_weight="1" android:text="@string/cancel" /> <Button android:id="@+id/right_button" style="?android:attr/borderlessButtonStyle" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_weight="1" android:text="@string/complete" /> </LinearLayout> ``` Here's one of the layouts that includes it: ``` <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/RelativeLayout1" android:layout_width="match_parent" android:layout_height="match_parent" > <TextView android:id="@+id/register_title_two" style="?android:attr/listSeparatorTextViewStyle" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_alignParentLeft="true" android:layout_alignParentTop="true" android:layout_margin="8dp" android:padding="8dp" android:text="@string/i_want_to" android:textColor="@android:color/holo_blue_dark" /> <RadioGroup android:id="@+id/extend_delete_alert_group" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_alignParentLeft="true" android:layout_below="@+id/register_title_two" > <RadioButton android:id="@+id/delete_alerts" android:layout_width="match_parent" android:layout_height="wrap_content" android:gravity="center_vertical" android:minHeight="32dp" android:padding="8dp" android:text="@string/delete_alerts" android:textSize="14sp" /> <RadioButton android:id="@+id/extend_alerts" android:layout_width="match_parent" android:layout_height="wrap_content" android:gravity="center_vertical" android:minHeight="32dp" android:padding="8dp" android:text="@string/extend_alerts" android:textSize="14sp" /> </RadioGroup> <include android:id="@+id/include1" android:layout_height="wrap_content" android:layout_width="wrap_content" android:layout_alignParentBottom="true" layout="@layout/two_button_bar" /> ``` I've read a few answers around and they all point to setting both the `include>` and `merge>` to `wrap_content` for height and width, but that is how I already had it, and it's still a no-go. Any ideas?

Original source

Related problems