错误构建版本布局

时间:2017-03-16 10:22:57

标签: android android-layout android-studio

当我按下构建版本时,我遇到了问题但是当我按下调试时没有问题:

  

错误:(52)错误:id" recycler_viewContainer"没有在任何地方定义。 [UnknownId]

     

错误:(52)错误:@ id / recycler_view不是同一RelativeLayout中的兄弟[NotSibling]

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:fab="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    android:id="@+id/main_layout"
    tools:context="ru.ifsoft.mymarketplace.StreamFragment">

    <LinearLayout
        android:orientation="vertical"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:id="@+id/container_body" >

        <android.support.v4.widget.SwipeRefreshLayout
            android:id="@+id/container_items"
            android:layout_height="0dp"
            android:layout_weight="1"
            android:layout_width="match_parent"
            android:background="@color/white">

            <android.support.v7.widget.RecyclerView
                android:id="@+id/recycler_view"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:clipToPadding="false"
                android:scrollbars="none" />

        </android.support.v4.widget.SwipeRefreshLayout>

    </LinearLayout>

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="New Text"
        android:id="@+id/message"
        android:layout_centerVertical="true"
        android:layout_centerHorizontal="true" />

    <com.melnykov.fab.FloatingActionButton
        android:id="@+id/fabButton"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginBottom="24dp"
        android:layout_marginRight="24dp"
        android:src="@drawable/ic_action_new"
        app:fabSize="normal"
        app:layout_anchor="@id/recycler_view"
        android:elevation="2dp"
        android:layout_marginEnd="41dp"
        android:layout_alignParentBottom="true"
        android:layout_alignParentRight="true"
        android:layout_alignParentEnd="true"
        fab:fab_colorNormal="@color/colorFloatActionButton"
        fab:fab_colorPressed="@color/colorFloatActionButton"
        fab:fab_colorRipple="@color/colorRipple" />

</RelativeLayout>

2 个答案:

答案 0 :(得分:0)

FloatingActionButton的变化

app:layout_anchor="@id/profileListView"

app:layout_anchor="@+id/profileContainer"

app:layout_anchor =“@ id / recycler_view”到

应用程式:layout_anchor = “@ + ID / container_body”

希望这会对你有所帮助。

答案 1 :(得分:0)

这是你的xml兄弟姐妹结构和错误。

Direct siblings with error

错误是,profileListView不是直接的兄弟姐妹。即,它位于直接兄弟中,LinearLayout profileContainer

Direct sibling id

因此我们将给出直接兄弟ID以解决问题。

Direct sibling id given

同样,为recycler_view的父级提供一个ID,并使用它来为recycler_view编制直接同级问题。

 <com.melnykov.fab.FloatingActionButton
    android:id="@+id/fabButton"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginBottom="24dp"
    android:layout_marginRight="24dp"
    android:src="@drawable/ic_action_new"
    app:fabSize="normal"
    app:layout_anchor="@+id/container_body" // Used id of the LinerLayout, which is the direct sibling of the root layout
    android:elevation="2dp"
    android:layout_marginEnd="41dp"
    android:layout_alignParentBottom="true"
    android:layout_alignParentRight="true"
    android:layout_alignParentEnd="true"
    fab:fab_colorNormal="@color/colorFloatActionButton"
    fab:fab_colorPressed="@color/colorFloatActionButton"
    fab:fab_colorRipple="@color/colorRipple" />
相关问题