我试图做一个有色的空视图占用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