Problems with <include> on relative layout, views always at the top

I have several layouts where I want inlcude/> bottom panel containing two buttons. Pretty simple, huh? Well, I am having problems with this, because the buttons are set to the top of the view regardless of the options that I set for it.

Here's what it looks like now.

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 is one of the layouts that includes:

 <?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 read several answers, and they all point to setting both include> and merge> to wrap_content for height and width, but I already had this, and it still doesn't go.

Any ideas?

+4
source share
2 answers

<include /> really just cut and pasted, and <merge /> means the union of RelativeLayout. Therefore, you need to provide these elements of the RelativeLayout rule, try adding:

 android:layout_above="@+id/button_container" 

In the separator view. And add:

 android:layout_alignParentBottom="true" 

In LinearLayout.

+2
source

You can specify the id in the tag in your xml and then the layout in your RelativeLayout that you want under it, you can just use layout_below="@id/-includedlayout-id

This will align the layout as you want it.

 <include android:id="@+id/include1" layout="-yourLayout-"/> <RelativeLayout ... android:layout_below="@id/include1> 
0
source

All Articles