2015-11-05 72 views
0

我想在RecyclerView上添加FAB來添加更多項目,但只顯示沒有FAT的RecyclerView或我放在這裏的任何東西。這是我的代碼:浮動操作按鈕在RecyclerView上不可視化。怎麼樣?

<LinearLayout 
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" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:orientation="horizontal" 
tools:context=".MainActivity"> 

<android.support.v7.widget.RecyclerView 
    android:id="@+id/lista" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content"> 
    </android.support.v7.widget.RecyclerView> 

<android.support.design.widget.FloatingActionButton 
    android:id="@+id/btnAnadir" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_margin="16dp" 
    android:src="@drawable/ic_add_white_24dp" 
    app:borderWidth="0dp" 
    app:layout_anchorGravity="bottom|center" 
    android:layout_gravity="right" /> 

回答

1

嘗試使用的FrameLayout代替LinearLayout作爲根佈局。

+0

謝謝,它的工作原理。 – user3523942