2017-03-22 39 views
1

我在android xml中遇到問題。我得到像上面的錯誤,但根據我的我沒有給我的XML的循環依賴。我試圖從最後1小時修復它,但我無法完成它。按照要求我已經在上面和下面使用。我在這裏附上我的xml。讓我知道是否有人可以指出我錯在哪裏。我的XML是像下面java.lang.IllegalStateException:在RelativeLayout中不存在循環依賴項:XML

<?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>

感謝很多:)

回答

0

你把layout_above和layout_below既可以只放上方或下方,並擴展視圖尋呼機嘗試將解決讓我知道,如果它得到解決

+0

是......你是對的我已經通過方式來完成它,你告訴......現在我面對陌生的問題。在上面的xml中ll_adLayout_latest是我從Java中隱藏的adview,名爲view.gone ...如果我隱藏它...底部工具欄將顯示一個頂部並且屏幕將變爲空白...您知道那裏有什麼問題嗎?謝謝 – Priya

+0

你會發布截圖 –

+0

請檢查https://ibb.co/ghOpdv – Priya

1

您在這裏使用循環依賴:

<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"> 

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