- <?xml version=“1.0” encoding=”utf-8″?>
- <ScrollView xmlns:android=“http://schemas.android.com/apk/res/android”
- android:layout_width=“fill_parent”
- android:layout_height=“wrap_content” >
- <HorizontalScrollView
- android:layout_width=“fill_parent”
- android:layout_height=“wrap_content” >
- <RelativeLayout
- android:layout_width=“fill_parent”
- android:layout_height=“fill_parent”>
- <TextView
- android:id=“@+id/textview1”
- android:layout_width=“wrap_content”
- android:layout_height=“wrap_content”
- android:text=“Scrolling view”
- android:textSize=“30dp” />
- <ImageView
- android:id=“@+id/imageview1”
- android:layout_width=“wrap_content”
- android:layout_height=“wrap_content”
- android:layout_toRightOf=“@id/textview1”
- android:src=“@drawable/item1” />
- <TextView
- android:id=“@+id/textview2”
- android:layout_width=“wrap_content”
- android:layout_height=“wrap_content”
- android:layout_toRightOf=“@id/imageview1”
- android:text=“Vertical and horizontal scrolling”
- android:textSize=“30dp” />
- <ImageView
- <span style=“color:#ff6666;”>android:id=”@+id/imageview2″
- </span> android:layout_width=“wrap_content”
- android:layout_height=“wrap_content”
- android:layout_below=“@id/textview1”
- android:src=“@drawable/item2” />
- <TextView
- android:id=“@+id/textview3”
- android:layout_width=“wrap_content”
- android:layout_height=“wrap_content”
- android:layout_below=“@id/imageview2”
- android:text=“Vertical and horizontal scrolling”
- android:textSize=“30dp” />
- <ImageView
- <span style=“color:#ff6666;”> android:id=”@+id/imageview2″</span>
- android:layout_width=“wrap_content”
- android:layout_height=“wrap_content”
- android:layout_below=“@id/textview3”
- android:src=“@drawable/item3” />
- </RelativeLayout>
- </HorizontalScrollView>
- </ScrollView>
Such an exception broke out, java.lang.IllegalStateException: Circular dependencies cannot exist in RelativeLayout.
The reason is that duplicate view ID names are reproduced in the RelativeLayout layout, and imageview2, textview3, and imageview2 have circular dependencies.
Solution: Modify the id of the last ImageView to imageview3. Avoid the control cycle dependency in RelativeLayout.
The essence is: the position of 1 depends on the position relative to 2 and 2 depends on the position relative to 1, but the two relative positions are contradictory.