В моем приложении для Android я объявляю пользовательское представление в отдельном XML-файле.
<?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>
Затем у меня есть файл main.xml, в который я хотел бы включить представление, объявленное в приведенном выше XML, следующим образом:
<?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>
Как вы можете видеть, я пытаюсь установить атрибут layout_toRightOf включенного представления, но он не установлен, как я могу видеть также в иерархическом просмотрщике
С другой стороны, если япросто скопируйте и вставьте содержимое файла download_interval_setter.xml в main.xml и объявите там параметр layout_toRightOf, вид будет располагаться справа, как я хочу.
Куда я иду не так?Спасибо