Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.2k views
in Technique[技术] by (71.8m points)

android - Why am I getting a CircularDependencyException?

Hey I am trying to make a notification for my file uploading notification. This is my XML: but it keeps giving me the error: Circular dependencies cannot exist in RelativeLayout. What am I doing wrong? I dont see anything wrong with it? I was also trying to make it look similar to the 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>
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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

Based on your xml file, I recommend you use LinearLayouts. There really isn't anything that you are doing here that can't be solved with two LL's and the parent RelativeLayout.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...