2017-03-16 82 views
0

當我按下構建版本我得到的問題,但是當我按調試是沒有問題的:錯誤編譯版本佈局

Error:(52) Error: The id "recycler_viewContainer" is not defined anywhere. [UnknownId]

Error:(52) Error: @id/recycler_view is not a sibling in the same 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> 
+0

change @ + id/profileListView而不是@id/profileListView –

+0

爲什麼不用'profileContainer'來代替? 'app:layout_anchor =「@ + id/profileContainer」' – Nizam

+0

我不明白我應該怎麼做@Nizam –

回答

0

這是您的xml兄弟姐妹結構和錯誤。

Direct siblings with error

的錯誤是,profileListView並不是直接的同胞。也就是說,它是直接兄弟裏面,LinearLayout中profileContainer

Direct sibling id

因此,我們將給予直接的兄弟ID來解決這個問題。

Direct sibling id given

同樣,給一個id的recycler_view父,並用它來SOVE直接兄弟問題的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" /> 
+0

現在編輯你請幫我 –

+0

RecylerView是另一種佈局。對?使用'app:layout_anchor =「@ + id/container_body」'爲那FloatingActionButton – Nizam

+0

我不明白同樣,給一個id給recycler_view的父項,並用它來解決recycler_view的直接兄弟問題。 –

0

變化FloatingActionButton

app:layout_anchor="@id/profileListView"

app:layout_anchor="@+id/profileContainer"

應用:layout_anchor = 「@ ID/recycler_view」 到

應用:layout_anchor = 「@ + ID/container_body」

希望這會幫助你。

+0

它的工作讓我像他們一樣的問題你能幫我嗎? 錯誤:(52)錯誤:@ id/recycler_view不是同一個RelativeLayout中的兄弟[NotSibling] –

+0

檢查或發佈您在其中使用recycle_view的xml文件。 –

+0

現在編輯你請幫我 –