不能够添加以下Recyclerview空视图 [英] Not able to add empty view below Recyclerview

查看:1194
本文介绍了不能够添加以下Recyclerview空视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是想我的手recyclerview和浮动操作按钮的应用程序。我所遇到的问题是,在浮动动作按钮阻碍与recyclerview的按钮。我抬头一看如何在Android应用程序,如手机应用程序(一个,你必须在gridvew显示的联系人),旨在解决这个问题,我看到有留在底部的空空间,给人recyclerview和浮动操作按钮,用户之间的空间只需滚动至底部,避免重叠。 我试图recyclerview后添加的视图,但不是它没有得到展示,也是这个观点应该随着recyclerview行移动。我在想什么,显示在recyclerview的最后一个观点。 我的布局文件:

 < RelativeLayout的的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android
                机器人:layout_width =match_parent
                机器人:layout_height =match_parent
                机器人:后台=#6fbababa>

    < android.support.v7.widget.RecyclerView
        机器人:ID =@ + ID / my_recycler_view
        机器人:layout_width =match_parent
        机器人:layout_height =WRAP_CONTENT
        机器人:滚动条=垂直/>

    <的ImageButton
        机器人:ID =@ + ID / button_floating_action
        机器人:layout_width =WRAP_CONTENT
        机器人:layout_height =WRAP_CONTENT
        机器人:layout_alignParentRight =真
        机器人:layout_alignParentEnd =真
        机器人:SRC =@可绘制/ ic_fab
        机器人:背景=@空
        机器人:layout_alignParentBottom =真
        机器人:layout_marginBottom =12dp
        机器人:layout_marginEnd =12dp
        机器人:layout_marginRight =12dp
        机器人:海拔=2DP/>

    <查看
        机器人:layout_width =match_parent
        机器人:layout_height =30dp
        机器人:layout_below =@ ID / my_recycler_view
        机器人:背景=@色/白/>

< / RelativeLayout的>
 

更新:修改布局code,使其工作

 < android.support.v7.widget.RecyclerView
机器人:ID =@ + ID / my_recycler_view
机器人:layout_width =match_parent
机器人:layout_height =match_parent
机器人:clipToPadding =假
机器人:paddingBottom会=30dp
机器人:滚动条=垂直/>
 

解决方案

添加底部填充到RecyclerView。 另外,不要使用安卓layout_height =WRAP_CONTENT除非你在布局管理器覆盖 onMeasure 。当前布局管理器还不支持包的内容。

添加属性机器人:clipToPadding =假来实现这一目标。 正如评论。

I was trying my hand with recyclerview and floating action button for an app. The problem I encountered is that the floating action button hinders with the buttons in recyclerview. I looked up how the android apps such as phone app(one where you have contacts displayed in gridvew) are designed to deal with this, I see that there is empty space left in the bottom which gives space between recyclerview and floating action button, user just needs to scroll to the bottom to avoid the overlap. I tried to add a view after recyclerview but not its not getting displayed, also this view should move along with the recyclerview rows. What am I missing to show a view in the end of the recyclerview. My layout file:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:background="#6fbababa">

    <android.support.v7.widget.RecyclerView
        android:id="@+id/my_recycler_view"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:scrollbars="vertical"/>

    <ImageButton
        android:id="@+id/button_floating_action"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentRight="true"
        android:layout_alignParentEnd="true"
        android:src="@drawable/ic_fab"
        android:background="@null"
        android:layout_alignParentBottom="true"
        android:layout_marginBottom="12dp"
        android:layout_marginEnd="12dp"
        android:layout_marginRight="12dp"
        android:elevation="2dp"/>

    <View
        android:layout_width="match_parent"
        android:layout_height="30dp"
        android:layout_below="@id/my_recycler_view"
        android:background="@color/white"/>

</RelativeLayout>

Update: Modified the layout code to make it work.

<android.support.v7.widget.RecyclerView 
android:id="@+id/my_recycler_view" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:clipToPadding="false" 
android:paddingBottom="30dp" 
android:scrollbars="vertical"/>

解决方案

Add bottom padding to the RecyclerView. Also, don't use android:layout_height="wrap_content" unless you've overridden onMeasure in the layout manager. Current layout managers do not yet support wrap content.

Add a attribute android:clipToPadding="false" to achieve the goal. As mentioned in comments.

这篇关于不能够添加以下Recyclerview空视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆