Development issues and Solutions--java.lang.illegalstateexception:circular dependencies cannot exist in Relativelayout

Source: Internet
Author: User

  1. <? XML version= "1.0" encoding="Utf-8"?>
  2. <ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
  3. android:layout_width="fill_parent"
  4. android:layout_height="wrap_content" >
  5. <Horizontalscrollview
  6. android:layout_width="fill_parent"
  7. android:layout_height="wrap_content" >
  8. <relativelayout
  9. android:layout_width="fill_parent"
  10. android:layout_height="fill_parent">
  11. <TextView
  12. android:id="@+id/textview1"
  13. android:layout_width="wrap_content"
  14. android:layout_height="wrap_content"
  15. android:text="scrolling View"
  16. android:textsize="30DP" />
  17. <ImageView
  18. android:id="@+id/imageview1"
  19. android:layout_width="wrap_content"
  20. android:layout_height="wrap_content"
  21. android:layout_torightof="@id/textview1"
  22. android:src="@drawable/item1" />
  23. <TextView
  24. android:id="@+id/textview2"
  25. android:layout_width="wrap_content"
  26. android:layout_height="wrap_content"
  27. android:layout_torightof="@id/imageview1"
  28. android:text="vertical and horizontal scrolling"
  29. android:textsize="30DP" />
  30. <ImageView
  31. <span style="color: #ff6666;" >android:id="@+id/imageview2"
  32. </span> android:layout_width="wrap_content"
  33. android:layout_height="wrap_content"
  34. android:layout_below="@id/textview1"
  35. android:src="@drawable/item2" />
  36. <TextView
  37. android:id="@+id/textview3"
  38. android:layout_width="wrap_content"
  39. android:layout_height="wrap_content"
  40. android:layout_below="@id/imageview2"
  41. android:text="vertical and horizontal scrolling"
  42. android:textsize="30DP" />
  43. <ImageView
  44. <span style="color: #ff6666;" > android:id="@+id/imageview2"</span>
  45. android:layout_width="wrap_content"
  46. android:layout_height="wrap_content"
  47. android:layout_below="@id/textview3"
  48. android:src="@drawable/item3" />
  49. </relativelayout>
  50. </horizontalscrollview>
  51. </ScrollView>

Out of this anomaly,java.lang.IllegalStateException:Circular dependencies cannot exist in Relativelayout.

The reason is that the duplicate view ID name is reproduced in the Relativelayout layout, and the imageview2 appears, textview3,imageview2 a cyclic dependency.

Solution: Change the ID of the last ImageView to IMAGEVIEW3. Avoid the control looping dependencies in Relativelayout.

The essence is: 1 of the position depends on the position of 2 2 and depends on the relative to the 1 but the two relative positions produced contradictions.

Development issues and Solutions--java.lang.illegalstateexception:circular dependencies cannot exist in Relativelayout

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.