【问题标题】:Circular dependencies cannot exist in RelativeLayout Android XML [closed]RelativeLayout Android XML中不能存在循环依赖项[关闭]
【发布时间】:2017-08-07 02:10:52
【问题描述】:

我正在尝试在 ExtendedViewPager 底部设置 Admob 横幅,但我没有成功。我收到Exception raised during rendering: Circular dependencies cannot exist in RelativeLayout 的错误 我希望我的智能横幅广告位于 XML 的底部。

我的 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_below="@+id/toolbar_imageDetails"
        android:background="@color/image_back"/>

    <com.github.clans.fab.FloatingActionMenu
        android:id="@+id/floating_menu"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        app:menu_colorNormal="@color/fab_menu"
        app:menu_labels_colorNormal="@color/btn_fab_labels_color"
        android:layout_marginRight="10dp"
        android:layout_marginBottom="10dp"
        android:layout_above="@+id/ll_adLayout_image"
        android:layout_alignParentRight="true" >

        <com.github.clans.fab.FloatingActionButton
            android:id="@+id/button_likeDislike"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            app:fab_colorNormal="@color/fab_button"
            android:src="@mipmap/fav"
            fab:fab_size="mini"
            fab:fab_label="Like (10)" />

        <com.github.clans.fab.FloatingActionButton
            android:id="@+id/button_share_image"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            app:fab_colorNormal="@color/fab_button"
            android:src="@mipmap/share_white"
            fab:fab_size="mini"
            fab:fab_label="Share" />

        <com.github.clans.fab.FloatingActionButton
            android:id="@+id/button_copy_text"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            app:fab_colorNormal="@color/fab_button"
            android:src="@mipmap/copy"
            fab:fab_size="mini"
            fab:fab_label="" />


    </com.github.clans.fab.FloatingActionMenu>

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

    </LinearLayout>

</RelativeLayout>

任何人都可以检查并帮助我解决问题吗?

【问题讨论】:

    标签: java android xml android-layout


    【解决方案1】:

    在这里你定义你的LinearLayout - floating_menu 下面的ll_adLayout_image 然后在ll_adLayout_image 上面定义你的floating_menu 线性布局这是循环依赖, 对于解决问题,您需要删除任何一个依赖项,

    已解决问题的代码:

    <?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_below="@+id/toolbar_imageDetails"
            android:background="@color/image_back"/>
    
        <com.github.clans.fab.FloatingActionMenu
            android:id="@+id/floating_menu"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            app:menu_colorNormal="@color/fab_menu"
            app:menu_labels_colorNormal="@color/btn_fab_labels_color"
            android:layout_marginRight="10dp"
            android:layout_marginBottom="10dp"
            android:layout_above="@+id/ll_adLayout_image"
            android:layout_alignParentRight="true" >
    
            <com.github.clans.fab.FloatingActionButton
                android:id="@+id/button_likeDislike"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                app:fab_colorNormal="@color/fab_button"
                android:src="@mipmap/fav"
                fab:fab_size="mini"
                fab:fab_label="Like (10)" />
    
            <com.github.clans.fab.FloatingActionButton
                android:id="@+id/button_share_image"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                app:fab_colorNormal="@color/fab_button"
                android:src="@mipmap/share_white"
                fab:fab_size="mini"
                fab:fab_label="Share" />
    
            <com.github.clans.fab.FloatingActionButton
                android:id="@+id/button_copy_text"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                app:fab_colorNormal="@color/fab_button"
                android:src="@mipmap/copy"
                fab:fab_size="mini"
                fab:fab_label="" />
    
    
        </com.github.clans.fab.FloatingActionMenu>
    
        <LinearLayout
            android:layout_alignParentBottom="true"
            android:id="@+id/ll_adLayout_image"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:orientation="vertical">
    
        </LinearLayout>
    
    </RelativeLayout>
    

    【讨论】:

      【解决方案2】:

      问题是因为布局参数中有循环引用造成的。

      您提供LinearLayout 属性android:layout_below="@+id/floating_menu"FloatingActionButton 您提供android:layout_above="@+id/ll_adLayout_image",这就是发生异常的原因。

      【讨论】:

      • 谢谢兄弟......它工作正常......你拯救了我的一天......我会在 5 分钟内接受答案。非常感谢
      • @AvantikaSharma 很高兴知道这一点。
      猜你喜欢
      • 1970-01-01
      • 2015-05-26
      • 1970-01-01
      • 2017-08-14
      • 2015-11-18
      • 2017-09-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多