Paddy1990
Paddy1990

Reputation: 946

Android Why am I getting circular dependency exception

Hi I can't figure out why I'm getting a circular dependency with my xml layout? I know what it is but don't know what's causing it.

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/scroll_frame"
android:layout_width="match_parent"
android:layout_height="match_parent" >

<RelativeLayout
    android:id="@+id/more_info"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="@color/transparent_black" >

    <Button
        android:id="@+id/start_test"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_above="@+id/top_content"
        android:layout_marginBottom="30dp"
        android:layout_marginLeft="40dp"
        android:layout_marginRight="40dp"
        android:layout_marginTop="10dp"
        android:onClick="onClickHandler"
        android:text="@string/start_test" />

    <WebView
        android:id="@+id/top_content"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_below="@+id/start_test" />
</RelativeLayout>

<WebView
    android:id="@+id/bottom_content"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_below="@+id/more_info"
    android:layout_alignParentBottom="true" />

Can Anyone help with this issue?

Thanks

Upvotes: 0

Views: 63

Answers (2)

Manish Dubey
Manish Dubey

Reputation: 4306

You are using

android:layout_above="@+id/top_content" 

in Button and,

android:layout_below="@+id/start_test" 

in WebView. Use only one.

Upvotes: 2

Pankaj Kumar
Pankaj Kumar

Reputation: 83008

You are writing android:layout_above="@+id/top_content" into Button and android:layout_below="@+id/start_test" into WebView. This is creating circular dependency for RelativeLayout.


Use either android:layout_above="@+id/top_content" or android:layout_below="@+id/start_test"


So either use

<RelativeLayout
    android:id="@+id/more_info"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="@color/transparent_black" >

    <Button
        ....
        android:layout_above="@+id/top_content"
        .... />

    <WebView
        android:id="@+id/top_content"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" />
</RelativeLayout>

Or

<RelativeLayout
    android:id="@+id/more_info"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="@color/transparent_black" >

    <Button
        android:id="@+id/start_test"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_marginBottom="30dp"
        android:layout_marginLeft="40dp"
        android:layout_marginRight="40dp"
        android:layout_marginTop="10dp"
        android:onClick="onClickHandler"
        android:text="@string/start_test" />

    <WebView
        android:id="@+id/top_content"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_below="@+id/start_test" />
</RelativeLayout>

Upvotes: 3

Related Questions