Я использую конструктор axml для создания пользовательского интерфейса. Я разделяю экран на 4 части относительного макета. Один я хочу найти между двумя другими, и при добавлении layout_above = "@id/myBottomView" я получаю ошибку компиляции (см. ниже). Но дизайнер рисует все правильно. как я могу это исправить?
<?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">
<View
android:layout_width = "10dp"
android:layout_height = "10dp"
android:layout_centerInParent = "true"
android:background = "#1212ed"
android:id = "@+id/view1">
</View>
<RelativeLayout
android:id = "@+id/topView1"
android:layout_width = "match_parent"
android:layout_height = "wrap_content">
<Button
android:id = "@+id/historyButton"
android:layout_width = "wrap_content"
android:layout_height = "wrap_content"
android:layout_alignParentLeft = "true"
android:layout_marginLeft = "10dip"
android:text = "History" />
<TextView
android:id = "@+id/label"
android:layout_centerInParent = "true"
android:layout_width = "wrap_content"
android:layout_height = "wrap_content"
android:text = "eFinder"/>
<Button
android:id = "@+id/libraryButton"
android:layout_width = "wrap_content"
android:layout_height = "wrap_content"
android:layout_alignParentRight = "true"
android:layout_marginRight = "10dip"
android:text = "Library" />
</RelativeLayout>
<RelativeLayout
android:id = "@+id/addScanView"
android:layout_width = "match_parent"
android:layout_height = "wrap_content"
android:layout_marginBottom = "20dp"
android:layout_marginTop = "20dp"
android:layout_below = "@id/view1"
android:layout_above = "@id/myBottomView">
<TextView
android:id = "@+id/scanCounter"
android:layout_width = "wrap_content"
android:layout_height = "wrap_content"
android:layout_alignParentTop = "true"
android:layout_centerHorizontal = "true"
android:text = "10/5 scans"/>
<Button
android:id = "@+id/addScansButton"
android:layout_width = "wrap_content"
android:layout_height = "wrap_content"
android:text = "Add Scans"
android:layout_below = "@id/scanCounter"
android:layout_centerHorizontal = "true"
android:layout_marginTop = "9.0dp" />
<TextView
android:layout_width = "wrap_content"
android:layout_height = "wrap_content"
android:layout_centerHorizontal = "true"
android:layout_below = "@id/addScansButton"
android:gravity = "bottom"
android:text = "Tap to find E"
android:layout_alignParentBottom = "true" />
</RelativeLayout>
<RelativeLayout
android:id = "@+id/myBottomView"
android:layout_width = "match_parent"
android:layout_height = "wrap_content"
android:layout_alignParentBottom = "true"
android:layout_marginBottom = "10.0dp">
<Button
android:layout_width = "wrap_content"
android:layout_height = "wrap_content"
android:layout_alignParentLeft = "true"
android:layout_marginLeft = "10dip"
android:text = "share" />
<Button
android:layout_width = "wrap_content"
android:layout_height = "wrap_content"
android:layout_alignParentRight = "true"
android:layout_marginRight = "10dip"
android:text = "options" />
</RelativeLayout>
</RelativeLayout>
Это то, что показывает мне дизайнер, и это правильно, но есть ошибка сборки:
Я получаю сообщение об ошибке: //Ресурсы/макет/Main.axml(0,0): Ошибка APT0000: Не найден ресурс, соответствующий заданному имени (в 'layout_above' со значением '@id/myBottomView'). (APT0000)
Переместите элемент RelativeLayout (myBottomView) выше в элемент (addScanView), который ссылается на него, макет анализируется сверху вниз.
<?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">
<RelativeLayout
android:id = "@+id/topView1"
android:layout_width = "match_parent"
android:layout_height = "wrap_content">
</RelativeLayout>
<RelativeLayout
android:id = "@+id/myBottomView"
android:layout_width = "match_parent"
android:layout_height = "wrap_content"
android:layout_alignParentBottom = "true"
android:layout_marginBottom = "10.0dp">
</RelativeLayout>
<RelativeLayout
android:id = "@+id/addScanView"
android:layout_below = "@id/view1"
android:layout_above = "@id/myBottomView">
</RelativeLayout>
</RelativeLayout>