2012-02-14 116 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 /左”

因为默认布局重力留,然后取出此行。没事的。

玩得开心@。@

相关问题