2012-02-14 67 views
4

嘿,我想爲我的文件上傳通知做出通知。這是我的XML:但它一直給我錯誤:在RelativeLayout中不存在循環依賴關係。我究竟做錯了什麼?我沒有看到它有什麼問題嗎?我也想使它看起來類似於瀏覽器下載爲什麼我會收到CircularDependencyException?

<?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> 

回答

9

RelativeLayout的「左」的嘗試基礎上,RelativeLayout的「正確」的位置,本身鋪陳。這是無法完成的,因爲正如例外所說,它是循環的。如果汽車還在行駛,如何根據另一輛汽車的停放情況停放汽車?

根據您的xml文件,我建議您使用LinearLayout s。你在這裏沒有任何事情可以用兩個LL和父親RelativeLayout來解決。

3

刪除行android:layout_toLeftOf =「@ + id/right」。您聲明的左側位於左側,然後右側位於左側。它是一個循環依賴,因爲它不知道首先佈局哪個元素。

0

您嘗試在佈局中互相引用兩個佈局。部分代碼顯示如下,

<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> 

會發生循環依賴異常。

如何解決?

設置一種佈局的重力型,其他佈局指這個。

對於這種情況,刪除機器人:layout_toRightOf = 「@ + ID /左」

因爲默認佈局重力留,然後取出此行。沒事的。

玩得開心@。@

相關問題