I have a button, A
, inside special_button.xml
, that I reuse on all my activities. Each activity has a root RelativeLayout
.
The problem: one of my activities has a button, B
, on the same position as A
. I decided to just move B
above A
, but I can't reference A
from the activity's xml.
Here are the xmls
special_button.xml
<?xml version="1.0" encoding="utf-8"?>
<merge xmlns:android="http://schemas.android.com/apk/res/android" >
<Button
android:id="@+id/A"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_marginBottom="15dp"
android:layout_marginRight="20dp"/>
</merge>
layout_main.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<include layout="@layout/special_button" />
<Button
android:id="@+id/B"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_above="<id to reference button A>"
android:layout_marginBottom="15dp"
android:layout_marginRight="20dp" />
</RelativeLayout>