Priya
Priya

Reputation: 37

java.lang.IllegalStateException: Circular dependencies cannot exist in RelativeLayout : XML

I am facing issue in android xml. I get error like above but as per my I have not given Circular dependencies in my xml. I am trying from last 1 hour for fix it but I am not able to complete it. I have used above and below as per requirement. I am attaching my xml here. Let me know if someone can point me where I am wrong. My XML is like below

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:fab="http://schemas.android.com/apk/res-auto"
    tools:context="com.karopass.karoshare.ImageDetails">

    <android.support.v7.widget.Toolbar
        android:id="@+id/toolbar_imageDetails"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@color/colorPrimary"
        android:theme="@style/AppTheme.AppBarOverlay"
        app:popupTheme="@style/AppTheme.PopupOverlay">
    </android.support.v7.widget.Toolbar>

    <com.example.utils.ExtendedViewPager
        android:id="@+id/view_pager_extended"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_above="@+id/pageNavCount"
        android:layout_below="@+id/toolbar_imageDetails"
        android:background="@color/image_back"/>

    <LinearLayout
        android:background="@color/colorPrimary"
        android:id="@+id/pageNavCount"
        android:orientation="horizontal"
        android:layout_above="@+id/devider"
        android:layout_width="match_parent"
        android:layout_height="20dp">



        <RelativeLayout
            android:layout_weight="3"
            android:id="@+id/new_time_count"
            style="@style/SelectableItemBackground"
            android:layout_width="0dp"
            android:layout_height="match_parent">

            <TextView
                android:id="@+id/txt_view"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="1 Month ago"
                android:textSize="12sp"
                android:paddingLeft="5sp"
                android:layout_centerVertical="true"
                android:textColor="#cccccc"
                android:gravity="center|start" />
        </RelativeLayout>







        <RelativeLayout

            android:layout_weight="1"
            android:id="@+id/new_share_count"
            style="@style/SelectableItemBackground"
            android:layout_width="0dp"
            android:layout_height="match_parent">
            <TextView
                android:id="@+id/share_count"
                android:layout_centerInParent="true"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="999"
                android:textSize="12sp"
                android:paddingLeft="5sp"
                android:layout_centerVertical="true"
                android:textColor="#cccccc"
                android:gravity="center|start" />
        </RelativeLayout>

        <RelativeLayout

            android:layout_weight="1"
            style="@style/SelectableItemBackground"
            android:id="@+id/new_save_count"
            android:layout_width="0dp"
            android:layout_height="match_parent">

            <TextView
                android:id="@+id/like_count"
                android:layout_centerInParent="true"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="999"
                android:textSize="12sp"
                android:paddingLeft="5sp"
                android:layout_centerVertical="true"
                android:textColor="#cccccc"
                android:gravity="center|start" />
        </RelativeLayout>



    </LinearLayout>

    <View
        android:id="@+id/devider"
        android:layout_width="match_parent"
        android:layout_height="1dp"
        android:layout_above="@+id/pageNavLayout"
        android:background="#ffffff" />

    <LinearLayout
        android:background="@color/colorPrimary"
        android:id="@+id/pageNavLayout"
        android:orientation="horizontal"
        android:layout_above="@+id/ll_adLayout_latest"
        android:layout_width="match_parent"
        android:layout_height="48dp">



        <RelativeLayout
            android:layout_weight="1"
            android:id="@+id/new_time"
            style="@style/SelectableItemBackground"
            android:clickable="true"
            android:layout_width="0dp"
            android:layout_height="match_parent">

            <ImageView
                android:layout_centerInParent="true"
                android:scaleType="fitCenter"
                android:src="@mipmap/ic_past_961"
                android:layout_width="@dimen/nav_but_size"
                android:layout_height="@dimen/nav_but_size" />
        </RelativeLayout>-->
        <TextView
            android:background="#ffffff"
            android:layout_width="1dp"
            android:layout_height="match_parent" />


        <RelativeLayout
            android:id="@+id/new_copy"
            android:clickable="true"
            style="@style/SelectableItemBackground"
            android:layout_weight="1"
            android:layout_width="0dp"
            android:layout_height="match_parent">

            <ImageView
                android:layout_centerInParent="true"
                android:src="@mipmap/ic_copy_96"
                android:layout_width="@dimen/nav_but_size"
                android:layout_height="@dimen/nav_but_size" />

        </RelativeLayout>

        <TextView
            android:background="#ffffff"
            android:layout_width="1dp"
            android:layout_height="match_parent" />

        <RelativeLayout

            android:layout_weight="1"
            android:id="@+id/new_save"
            style="@style/SelectableItemBackground"
            android:clickable="true"
            android:layout_width="0dp"
            android:layout_height="match_parent">
            <ImageView
                android:layout_centerInParent="true"
                android:src="@mipmap/ic_save_96"
                android:layout_width="@dimen/nav_but_size"
                android:layout_height="@dimen/nav_but_size" />
        </RelativeLayout>
        <TextView
            android:background="#ffffff"
            android:layout_width="1dp"
            android:layout_height="match_parent" />

        <RelativeLayout

            android:layout_weight="1"
            android:id="@+id/new_share"
            style="@style/SelectableItemBackground"
            android:clickable="true"
            android:layout_width="0dp"
            android:layout_height="match_parent">
            <ImageView
                android:layout_centerInParent="true"
                android:src="@mipmap/ic_share_96"
                android:layout_width="@dimen/nav_but_size"
                android:layout_height="@dimen/nav_but_size" />
        </RelativeLayout>
        <TextView
            android:background="#ffffff"
            android:layout_width="1dp"
            android:layout_height="match_parent" />

        <RelativeLayout

            android:layout_weight="1"
            style="@style/SelectableItemBackground"
            android:clickable="true"
            android:id="@+id/new_fav"
            android:layout_width="0dp"
            android:layout_height="match_parent">

            <ImageView
                android:layout_centerInParent="true"
                android:src="@mipmap/ic_hearts_96"
                android:layout_width="@dimen/nav_but_size"
                android:layout_height="@dimen/nav_but_size"/>
        </RelativeLayout>



    </LinearLayout>

    <LinearLayout
        android:id="@+id/ll_adLayout_latest"
        android:layout_alignParentBottom="true"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:orientation="vertical">

    </LinearLayout>

</RelativeLayout>

Thanks a lot :)

Upvotes: 1

Views: 768

Answers (2)

R.R.M
R.R.M

Reputation: 790

You are using circular dependency here :

<LinearLayout
    android:background="@color/colorPrimary"
    android:id="@+id/pageNavCount"
    android:orientation="horizontal"
    android:layout_above="@+id/devider"
    android:layout_width="match_parent"
    android:layout_height="20dp">

and

 <View
    android:id="@+id/devider"
    android:layout_width="match_parent"
    android:layout_height="1dp"
    android:layout_above="@+id/pageNavLayout"
    android:background="#ffffff" />

Upvotes: 2

Dina Gar
Dina Gar

Reputation: 130

you are putting layout_above and layout_below both to the extended view pager put only above or below and try it will solve let me know if its get solved

Upvotes: 1

Related Questions