I have two widgets within a RelativeLayout that must reference each other. Technically it is not a circular reference since the widget A is vertically aligned with widget B and widget B is horizontally aligned with widget A. Here is my code (condensed):
<Button android:id="@+id/btnLanguageFrom"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_toLeftOf="@id/imgArrow"
android:text="English" />
<ImageView android:id="@+id/imgArrow"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="10dp"
android:layout_alignParentTop="true"
android:layout_alignBottom="@id/btnLanguageFrom"
android:layout_centerHorizontal="true"
android:src="@drawable/arrow_right" />
However when I build I get this error:
Error: No resource found that matches the given name (at 'layout_toLeftOf' with value '@id/imgArrow').
Interestingly, the Graphical Layout view in Eclipse displays it correctly and doesn't complain about the circular reference.
I don't see the problem with two widgets referencing each other along different dimensions (horizontal and vertical) since it cannot cause an infinite loop. Is there any way around this problem? This is the only way I know to get the layout I need.
Thanks in advance, Barry P.S. Is there any way to declare an id in advance, like in C/C++?