2015-11-05 70 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