Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I'm relatively new to Android and I've stucked with the following problem. I have an xml layout code, which seems to be working on 1.5, but fails on 1.6 and further with Circular dependencies are not allowed with RelativeLayout. I've googled some info on that error, and I got the basics. Still too few info about this topic. I still can't figure, where exactly that circular dependences occur in my code. Please, could some of you point me to the lines, where that happens, and explain why it so?

<LinearLayout  
    android:orientation="horizontal"
    android:layout_width="0dip"
    android:layout_weight="1"
    android:layout_height="wrap_content"
    android:gravity="center_horizontal">
    <ImageView
        android:paddingTop="3dip"
        android:id="@+id/typeicon"
        android:scaleType="center"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"/>  
</LinearLayout>

<RelativeLayout 
    android:orientation="vertical"
    android:layout_width="0dip"
    android:layout_weight="6.5"
    android:layout_height="fill_parent"
    android:paddingRight="20dip">
    <RelativeLayout
        android:layout_alignParentTop="true"
        android:id="@+id/toprellistlayout"
        android:layout_width="fill_parent"
        android:layout_weight="1"
        android:layout_height="wrap_content">
        <TextView
            android:id="@+id/trannumbertext"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:textSize="16sp"
            android:textStyle="bold"
            android:layout_alignParentLeft="true"/>
        <TextView
            android:id="@+id/summtext"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:textSize="16sp"
            android:layout_alignParentRight="true"
            android:textStyle="bold"/>
    </RelativeLayout>
    <TextView
        android:layout_below="@id/toprellistlayout"
        android:id="@+id/maintranstext"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:layout_gravity="center"
        android:textSize="13sp"
        android:textStyle="bold"
    />
    <RelativeLayout
        android:layout_width="fill_parent"
        android:layout_weight="1"
        android:paddingTop="4dip"
        android:layout_below="@id/maintranstext"
        android:id="@+id/toprellistlayout"
        android:layout_height="wrap_content">
        <TextView
            android:id="@+id/datetext"
            android:layout_width="wrap_content"
            android:layout_height="fill_parent"
            android:layout_weight=".3"
            android:textSize="11sp"
            android:text="01.01.0000 00:00:00"
            android:textStyle="bold"
            android:gravity="center"
            android:layout_alignParentLeft="true"/>
        <TextView
            android:id="@+id/statusview"
            android:layout_width="wrap_content"
            android:layout_height="fill_parent"
            android:layout_weight=".7"
            android:gravity="center"
            android:text="@string/finlist_rejected"
            android:drawableLeft="@drawable/cross"
            android:drawablePadding="5dip"
            android:background="@android:id/empty"
            android:layout_alignParentRight="true"
            android:textStyle="bold"
            android:textSize="11sp"/>
    </RelativeLayout>
</RelativeLayout>

See Question&Answers more detail:os

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

1 Answer

After an hour by partially deleting the lines, I've finally figured, where that "Circular dependencies" were.

It appears, that when SDK parses RelativeLayout xml, and positioning the items - it can't take, for example, the view C, which is below the view B, which is below the view A. If you look carefully - you'll find that part in my code.
The solution - is to make an additional RelativeLayout, in which to place the views C and B.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...