I'm trying to make an empty view that is colored take up the remaining space after a RecyclerView. I've looked at different StackOverflow solutions but nothing works. Essentially I want something like this :
________________________
| |
| |
| |
| Recycler view |
| |
| ------------------- |
| colored empty view |
| |
| |
| |
| |
| |
_________________________
It should shrink as the RecyclerView grows.
________________________
| |
| |
| |
| Recycler view |
| |
| |
| |
| |
| |
| ------------------- |
| colored empty view |
| |
| |
_________________________
However if the RecyclerView exceeds one screen's worth, there should be no empty view. Here's what I have so far:
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:fab="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/bla_bla_layout">
<android.support.v7.widget.RecyclerView
android:id="@+id/bla_bla_recyclerview"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<View
android:background="@color/grayBackground"
android:layout_gravity="bottom"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
<com.melnykov.fab.FloatingActionButton
android:id="@+id/fab"
android:contentDescription="@string/add_bla"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|right"
android:layout_margin="16dp"
android:src="@drawable/add_bla_icon"
fab:fab_colorNormal="@color/primary"
fab:fab_colorPressed="@color/primary_pressed"
fab:fab_colorRipple="@color/ripple" />
</FrameLayout>
EDIT This is not a duplicate of the mentioned question and you could see this if you read both questions. The solution to my question should be purely xml, layout based. By "empty view" I mean just some colored rectangle BELOW the existing RecyclerView, not a textview that actually says "Empty view" when there's no data in the RecylerView.