我試圖做一個有色的空視圖佔用RecyclerView後的剩餘空間。我查看了不同的StackOverflow解決方案,但沒有任何效果。基本上我想要這樣的東西:讓RecyclerView後空視圖佔用剩餘空間?
________________________
| |
| |
| |
| Recycler view |
| |
| ------------------- |
| colored empty view |
| |
| |
| |
| |
| |
_________________________
It should shrink as the RecyclerView grows.
________________________
| |
| |
| |
| Recycler view |
| |
| |
| |
| |
| |
| ------------------- |
| colored empty view |
| |
| |
_________________________
但是,如果RecyclerView超過一個屏幕的價值,應該沒有空視圖。這是我到目前爲止有:
<?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>
編輯 這不是提到的問題的副本,你可以看到這一點,如果你讀這兩個問題。我的問題的解決方案應該是純粹的xml,基於佈局。通過「空視圖」,我的意思是在現有的RecyclerView下面有一些彩色矩形,而不是RecylerView中沒有數據時實際上顯示爲「空視圖」的文本視圖。
如果你要downvote我的問題,請告訴我爲什麼...... – Tariq
可能的重複[如何顯示與RecyclerView空視圖?](http://stackoverflow.com/questions/28217436/how-to-show-an-empty-view-with-a-recyclerview) –
這根本不是我的問題。他的問題甚至不是一個佈局問題。相信我,我已經看到了所有,並嘗試了許多類似問題的解決方案。如果你找到一個可以工作的東西,我會很高興。 – Tariq