【发布时间】:2015-01-04 17:49:39
【问题描述】:
我正在尝试使用 recyclerview 和应用程序的浮动操作按钮。我遇到的问题是浮动操作按钮阻碍了recyclerview中的按钮。我查看了 Android 应用程序,如手机应用程序(您在 gridvew 中显示联系人的应用程序)是如何设计来处理这个问题的,我看到底部有空白空间,在 recyclerview 和浮动操作按钮之间留出了空间,用户只需要滚动到底部以避免重叠。 我试图在 recyclerview 之后添加一个视图,但它没有显示出来,这个视图也应该与 recyclerview 行一起移动。在回收站视图的末尾显示视图我缺少什么。 我的布局文件:
<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>
更新:修改了布局代码以使其工作。
<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"/>
【问题讨论】:
-
所有你需要的是让 RecyclerView 最后绘制。检查我的答案中的示例。 HTH
标签: android android-layout android-recyclerview