Приложение, над которым я работаю, имеет 4 вкладки, 3 из которых имеют много общих функций, в том числе панель навигации внизу с кнопками Назад, Редактировать и Карта. точно одинаковый xml во всех 3 макетах, поэтому я пытаюсь высушить это, выделив этот xml в отдельный компонент, включая его, и затем перейдя оттуда.
Ранее у меня было
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="fill_parent"
android:layout_width="fill_parent">
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/showedit_toolbar"
style="@style/showItemToolbar">
<ImageButton android:id="@+id/show_person_back_button"
style="@style/blackToolbarButton"
android:src="@drawable/left_white_arrow"
android:layout_alignParentLeft="true"/>
<Button android:id="@+id/show_person_map_button"
style="@style/blackToolbarButton"
android:text="map"
android:layout_alignParentRight="true"/>
<Button android:id="@+id/show_person_edit_button"
style="@style/blackToolbarButton"
android:text="edit"
android:layout_toLeftOf="@id/show_person_map_button"/>
</RelativeLayout>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="fill_parent"
android:layout_width="fill_parent"
android:layout_above="@id/showedit_toolbar"
style="@style/CoinLightTheme">
// Lots more layout omitted
Я извлек бит, который повторяется, в XML-файл с именем show_toolbar.xml, изменив имена переменных, чтобы сделать его более общим для всех трех представлений
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/show_toolbar"
style="@style/showItemToolbar">
<ImageButton style="@style/blackToolbarButton"
android:src="@drawable/left_white_arrow"
android:layout_alignParentLeft="true"
android:id="@+id/show_back_button"/>
<Button android:id="@+id/show_map_button"
style="@style/blackToolbarButton"
android:text="map"
android:layout_alignParentRight="true"/>
<Button android:id="@+id/show_edit_button"
style="@style/blackToolbarButton"
android:text="edit"
android:layout_toLeftOf="@id/show_map_button"/>
</RelativeLayout>
Затем из моего исходного файла макета я заменил этот большой блок кода на
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="fill_parent"
android:layout_width="fill_parent">
<include android:id="@+id/show_toolbar" layout="@layout/show_toolbar"/>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="fill_parent"
android:layout_width="fill_parent"
android:layout_above="@id/showedit_toolbar"
style="@style/CoinLightTheme">
Теперь проблема в том, что представление больше не отображается. Я все еще могу нажимать кнопки, и они реагируют (т.е., если я нажимаю в углу, где должна быть кнопка, она все еще работает), но я не вижу кнопки или панель, на которой они были нарисованы.
Я не могу найти очень хорошую документацию о том, как должен работать Include, поэтому, возможно, я использую его неправильно. Любая помощь будет оценена
До
До http://i34.tinypic.com/2dl0hm1.png
* После 1023 *