开发者

Circular dependencies, need some help with exact code

开发者 https://www.devze.com 2023-03-15 04:44 出处:网络
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 no

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_weigh开发者_运维知识库t="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>


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消