How to fix Illegal State Exception-Circular dependencies cannot exist in RelativeLayout
What is this error?This is mostly a layout error which comes in RelativeLayout. Basically when we tried to put two views in a RelativeLayout one after another and then commands to place above/below of each other, then this error happens. See the below code: If will see the above code properly, then in the ImageView we have written
android:layout_above="@+id/imageLabelView"to place it on top of the TextView. And also inside the TextView we have written
android:layout_below="@id/image_home"to place it below the ImageView. So it’s making a circular dependency which throws the error.
How to fix?Simply place the TextView to parent_bottom by giving the command
android:layout_alignParentBottom="true"and make the ImageView to on above of this as it is now. Something like below: Or another option could just make the ImageView to top of the parent and put the TextView to its below.