0
我試圖只在Recycler View位置處於頂部時顯示浮動操作按鈕。無論如何,我可以做到這一點?隱藏Android中的浮動操作按鈕,除非Recycler View中的位置位於頂部
這是我目前的佈局文件:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:background="#BBB"
android:layout_height="match_parent">
<android.support.v7.widget.RecyclerView
android:id="@+id/postsRecyclerView"
android:layout_width="match_parent"
android:scrollbars="vertical"
android:layout_height="match_parent" />
<android.support.design.widget.FloatingActionButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_margin="16dp"
android:src="@drawable/icon_post" />
</RelativeLayout>
感謝:]
http://stackoverflow.com/questions/31617398/floatingactionbutton-hide-on-list-scroll的可能的複製。 –
我嘗試過使用該功能,但我認爲使用回收站視圖而不是列表視圖 – Lunkie
嘗試此操作:https://mzgreen.github.io/2015/06/23/How-to-hideshow-Toolbar-when -list-is-scrolling%28part3%29/ –