In my Android app I declare a custom view in a separate XML file.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
android:id="@+id/download_interval_setter"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical">
<Button
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:id="@+id/Button_interval_up"
style="?android:attr/buttonStyleSmall">
</Button>
<EditText
android:id="@+id/Download_interval"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="1"
android:numeric="integer">
</EditText>
<Button
android:id="@+id/Button_interval_down"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
>
</Button>
</LinearLayout>
Then I have my main.xml file where I would like to include the view declared in above XML like this:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<ToggleButton android:layout_height="wrap_content"
android:id="@+id/XMLStart"
android:textOn="@string/auto_update_on"
android:textOff="@string/auto_update_off"
android:layout_width="wrap_content" />
<include layout="@layout/download_interval_setter"
android:layout_toRightOf="@id/XMLStart"/>
<Button android:layout_height="wrap_content"
android:id="@+id/ShowRadars"
android:text="@string/show_radars"
android:layout_width="wrap_content"
android:layout_below="@id/XMLStart"/>
<Button android:layout_height="wrap_content"
android:id="@+id/ShowAccidents"
android:text="@string/show_accidents"
android:layout_width="wrap_content"
android:layout_toRightOf="@id/ShowRadars"
android:layout_below="@id/XMLStart"/>
<Button android:layout_height="wrap_content"
android:id="@+id/ShowConstraints"
android:text="@string/show_constraints"
android:layout_width="wrap_content"
android:layout_below="@id/ShowRadars"/>
<Button android:layout_height="wrap_content"
android:id="@+id/ShowPatrols"
android:text="@string/show_patrols"
android:layout_width="wrap_content"
android:layout_below="@id/ShowRadars"
android:layout_toRightOf="@id/ShowConstraints"/>
</RelativeLayout>
As you can see I am trying to set the layout_toRightOf attribute of the included view but it is not set, as I can see also in hierarchyviewer
On the other hand if I simply copy-paste the content of the download_interval_setter.xml file to main.xml and declare the layout_toRightOf parameter there , the view will be positioned to right of as I want.
Where am I going wrong? Thanks