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
149 views
in Technique[技术] by (71.8m points)

android - Circular dependencies, need some help with exact code

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

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

1 Reply

0 votes
by (71.8m points)

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.


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

...