0

When I add FAB my recyclerview won't show items. In android studios preview everything looks fine, but when I launch the app list is empty.

<android.support.design.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/main_content"
android:layout_width="match_parent"
android:layout_height="match_parent">

<android.support.v7.widget.RecyclerView
    android:id="@+id/list"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:scrollbars="vertical"
    android:clickable="true"
    android:focusable="true"
    android:focusableInTouchMode="true"
    tools:listitem="@layout/item"
    xmlns:tools="http://schemas.android.com/tools"/>

<android.support.design.widget.FloatingActionButton
    android:layout_height="wrap_content"
    android:layout_width="wrap_content"
    app:layout_anchor="@id/list"
    app:layout_anchorGravity="bottom|right|end"
    android:layout_margin="5dp"
    android:clickable="true"/>
</android.support.design.widget.CoordinatorLayout>
  • 1
    At FloatingActionButton please add `android:layout_gravity="bottom|right"` and specify the `android:src="@drawable/your_drawable"` – muazhud Mar 15 '17 at 19:48
  • does this help [CoordinatorLayout with RecyclerView](http://stackoverflow.com/a/30555460/6689101) – zombie Mar 15 '17 at 23:08
  • It is working for my case.I think there are some issues in your layout item here tools:listitem="@layout/item" – Android Geek Mar 16 '17 at 04:46

1 Answers1

0

it's either fab button size or placement problem... rather than giving width and height wrap_content give in dp like 30dp and 30dp.. and try

Tapan Kumar Patro
  • 767
  • 1
  • 7
  • 18
  • Still the same problem. After some time trying to fix this I found out that as soon as I put recyclerview in another layout (in this case coordinator) it doesn't display anymore, even if there is no FAB – Aurimas Žarskis Mar 15 '17 at 21:05