[英]Hide floating action button
更新:我只是通過監聽 NestedScrollView 的滾動更改事件並在那里進行適當的處理來解決這個問題。
我正在按照本教程為我的FloatingActionButton
顯示和隱藏設置動畫。 但它並不適合我的布局。 我的布局是這樣的:
它里面有一個 NestedScrollView 和一些 RecyclerView。 當我通過觸摸 NestedScrollView 的區域滾動時, FloatingActionButton
按預期進行動畫處理。 但是當我通過觸摸RecyclerViews
之一的區域滾動時, FloatingActionButton
根本沒有動畫。 當我嘗試調試我的代碼時,我意識到當我通過觸摸RecyclerView
的區域滾動時不會調用onNestedScroll
方法。
從您的 xml 布局中注釋掉或刪除此代碼塊
<android.support.design.widget.FloatingActionButton
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="16dp"
android:clickable="true"
android:src="@drawable/ic_done"
app:layout_anchor="@id/viewA"
app:layout_anchorGravity="bottom|right|end"/>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.