如何在RelativeLayout中找到导致循环依赖的内容

时间:2013-04-16 21:53:00

标签: android android-layout relativelayout

我正在接收FC的堆栈跟踪,但我无法重现FC。我错过了什么?

在java代码中,根据应用程序的状态,某些视图设置为View.GONEView.VISIBLE。在LayoutParams我只更改大小和边距。

2嵌套RelativeLayouts是因为活动具有半透明主题,第二个是用于可由用户应用的alphafilter。

任何帮助都会很棒!

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/FNContainer"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@color/clr_background"
android:paddingTop="8dp" >

<RelativeLayout
    android:id="@+id/AlphaContainer"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" >

    <xx.xxxxxx.guielements.Footer
        android:id="@+id/footerInclude"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true" />

    <xx.xxxxxx.guielements.RoseImageView
        android:id="@+id/RoseView"
        android:layout_width="fill_parent"
        android:layout_height="200dp"
        android:layout_above="@id/footerInclude"
        android:layout_centerHorizontal="true"
        android:layout_margin="5dp" />

    <TextView
        android:id="@+id/tvBeschrijving"
        android:layout_width="fill_parent"
        android:layout_height="250dp"
        android:layout_alignParentTop="true"
        android:layout_alignParentLeft="true"
        android:layout_marginLeft="8dp" />

    <xx.xxxxxx.guielements.HmpImageView
        android:id="@+id/HmpView"
        android:layout_width="200dp"
        android:layout_height="200dp"
        android:layout_alignParentLeft="true"
        android:layout_below="@id/tvBeschrijving"
        android:layout_marginLeft="8dp" />

    <TextView
        android:id="@+id/tvDistToEnd"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_below="@id/HmpView"
        android:text="TC Eind: 1253m"
        android:textSize="20sp"
        android:textStyle="bold" />

    <TextView
        android:id="@+id/tvSnelheid"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true"
        android:layout_alignParentRight="true"
        android:gravity="top|right"
        android:text="120"
        android:textSize="70sp"
        android:textStyle="bold" />

    <TextView
        android:id="@+id/tvSnelheidAanduiding"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentRight="true"
        android:layout_below="@id/tvSnelheid"
        android:gravity="top|right"
        android:text="km/u"
        android:textSize="20sp" />

    <TextView
        android:id="@+id/tvVavg"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentRight="true"
        android:layout_below="@id/tvSnelheidAanduiding"
        android:text="120"
        android:textSize="70sp"
        android:textStyle="bold" />
    <TextView
        android:id="@+id/tvVavgAanduiding"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentRight="true"
        android:layout_below="@id/tvVavg"
        android:gravity="top|right"
        android:text="Ø km/u"
        android:textSize="20sp" />

    <TextView
        android:id="@+id/tvVmaxOnderbord"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_above="@id/footerInclude"
        android:layout_alignParentRight="true"
        android:background="@drawable/onderbord"
        android:gravity="center"
        android:text="6-18h"
        android:textSize="20sp"
        android:textStyle="bold"
        android:visibility="gone" />

    <TextView
        android:id="@+id/tvVmax"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_above="@id/tvVmaxOnderbord"
        android:layout_alignParentRight="true"
        android:background="@drawable/bg_vmax"
        android:gravity="center"
        android:text="120"
        android:textSize="20sp"
        android:textStyle="bold"
        android:visibility="gone" />



</RelativeLayout>

java.lang.IllegalStateException: Circular dependencies cannot exist in RelativeLayout
at android.widget.RelativeLayout$DependencyGraph.getSortedViews(RelativeLayout.java:1321)
at android.widget.RelativeLayout.sortChildren(RelativeLayout.java:316)
at android.widget.RelativeLayout.onMeasure(RelativeLayout.java:337)
at android.view.View.measure(View.java:15562)
at android.widget.RelativeLayout.measureChildHorizontal(RelativeLayout.java:617)
at android.widget.RelativeLayout.onMeasure(RelativeLayout.java:399)
at android.view.View.measure(View.java:15562)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5109)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:310)
at android.view.View.measure(View.java:15562)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5109)
at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1396)
at android.widget.LinearLayout.measureVertical(LinearLayout.java:681)
at android.widget.LinearLayout.onMeasure(LinearLayout.java:574)
at android.view.View.measure(View.java:15562)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5109)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:310)
at com.android.internal.policy.impl.PhoneWindow$DecorView.onMeasure(PhoneWindow.java:2397)
at android.view.View.measure(View.java:15562)
at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:1987)
at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:1228)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1401)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1121)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:4598)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:725)
at android.view.Choreographer.doCallbacks(Choreographer.java:555)
at android.view.Choreographer.doFrame(Choreographer.java:525)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:711)
at android.os.Handler.handleCallback(Handler.java:615)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4921)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1038)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:805)
at dalvik.system.NativeStart.main(Native Method)

2 个答案:

答案 0 :(得分:2)

我看起来想你的xml并且它看起来不像你有任何循环引用,如果你说你正在设置一些视图已经不见了我看看android:layout_alignWithParentIfMissing="true"你可以找到一个例子{ {3}}

我也不会尝试将您的任何观点设置为已消失,看看您是否还有问题。

答案 1 :(得分:0)

通常,当您将视图A设置为与另一个视图B对齐,并且视图B与A对齐时,会发生这种情况,从而产生循环依赖关系。

当您设置另一个视图的ID时,会出现上面,下面的属性以及对齐。