Why am I getting a CircularDependencyException?

Hi, I am trying to make a notification for my file upload notification. This is my XML: but it continues to give me an error: circular dependencies cannot exist in RelativeLayout. What am I doing wrong? I see nothing wrong with that? I also tried to make it look like a browser downloader

<?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:padding="5dp"> <RelativeLayout android:layout_width="fill_parent" android:layout_height="fill_parent" android:id="@+id/left" android:layout_toLeftOf="@+id/right"> <ImageView android:id="@+id/status_icon" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentTop="true" /> <TextView android:id="@+id/progress_text" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_below="@+id/status_icon" android:text="0%" /> </RelativeLayout> <RelativeLayout android:layout_width="fill_parent" android:layout_height="fill_parent" android:id="@+id/right" android:layout_toRightOf="@+id/left"> <TextView android:id="@+id/status_text" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_alignParentTop="true" /> <ProgressBar android:id="@+id/status_progress" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_below="@id/status_text" android:progressDrawable="@android:drawable/progress_horizontal" android:indeterminate="false" android:indeterminateOnly="false" /> </RelativeLayout> </RelativeLayout> 
+4
source share
3 answers

RelativeLayout "left" is trying to stand out due to the location of RelativeLayout "right". This cannot be done because, as the exception says, it is circular. How can you park a car based on parking another car if that car is still moving?

Based on your xml file, I recommend using LinearLayout s. There really is nothing that you do here that cannot be solved with two LLs and a parent RelativeLayout.

+9
source

Remove the line android: layout_toLeftOf = "@ + id / right". You announce that you will remain to the left of the right, and then to the right to be on the right. His circular dependence, because she does not know which element to lay out in the first place.

+3
source

You are trying to reference each other's two layouts in your layout. Some of the codes show, as shown below,

 <RelativeLayout android:layout_width="fill_parent" android:layout_height="fill_parent"> <RelativeLayout android:id="@+id/left" android:layout_toLeftOf="@+id/right" /> <RelativeLayout android:id="@+id/right" android:layout_toRightOf="@+id/left" /> </RelativeLayout> 

This will eliminate cyclical dependency.

How to fix?

Set the gravity type of one layout, another location refers to it.

In this case, remove android: layout_toRightOf = "@ + id / left"

Since gravity remains by default, delete this line. This will be good.

Good luck @. @

0
source

Source: https://habr.com/ru/post/1396505/


All Articles