I am getting compilation error in axml where I have referenced the item before declaring it.
As far as I know, Android doesn't have any such constraints. Moreover if I copy paste the same layout in Android studio it works fine.
Does anyone know a workaround of this issue in Xamarin.Android
The error is:
error APT0000: No resource found that matches the given name (at 'layout_below' with value '@id/textView1').
Here is a simplified version of layout to generate the error:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:minWidth="25px"
android:minHeight="25px">
<Button
android:id="@+id/button1"
android:text="Button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_below="@id/textView1" />
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:text="Hello World" />
</RelativeLayout>
@+id
prefix so a new resource id is generated. You could work around this same scenario by ensuring all views have resource ids in a sequential manner (such as moving yourButton
view XML below yourTextView
view XML). You can be a bit liberal with your usage of@+id
as theaapt
tooling is smart enough to know if the resource id already exists or not. stackoverflow.com/a/6646113/1048571 – Jon Douglas Aug 14 '18 at 20:40