有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java如何实现像playstore应用程序那样的向下滚动隐藏操作栏?

如何实现像play store应用程序那样的向下滚动隐藏操作栏? 有任何参考项目(github或任何)或提示吗

这是我的基本活动代码,包含了动作条和片段

<RelativeLayout xmlns:安卓="http://schemas.安卓.com/apk/res/安卓"
    安卓:layout_width="match_parent"
    安卓:layout_height="match_parent">
    <RelativeLayout
        安卓:layout_width="match_parent"
        安卓:layout_height="wrap_content"
        安卓:background="#F44336"
        安卓:id="@+id/toolbarrel">
        <安卓.support.v7.widget.Toolbar
            安卓:id="@+id/toolbar"
            安卓:layout_width="match_parent"
            安卓:layout_height="wrap_content"
            安卓:background="?attr/colorPrimary"
            安卓:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
            />
        <com.quinny898.library.persistentsearch.SearchBox
            安卓:layout_width="wrap_content"
            安卓:id="@+id/searchbox"
            安卓:layout_height="wrap_content"
            安卓:visibility="gone"
            安卓:elevation="3dp"
            安卓:background="#F44336"
            安卓:layout_alignParentLeft="true"
            安卓:layout_alignParentTop="true" />
    </RelativeLayout>
    <FrameLayout
        安卓:layout_below="@id/toolbarrel"
        安卓:id="@+id/frame_container"
        安卓:layout_width="match_parent"
        安卓:layout_height="match_parent">

    </FrameLayout>
</RelativeLayout>

共 (1) 个答案

  1. # 1 楼答案

    尝试使用协调器布局

    CoordinatorLayout扩展了谷歌实现许多材料设计滚动效果的能力。目前,该框架中提供了几种方法,允许它在不需要编写自定义动画代码的情况下工作

    有关Handling Scrolls with CoordinatorLayout的更多信息

     <android.support.design.widget.CoordinatorLayout
            android:id="@+id/main_content"
            xmlns:android="http://schemas.android.com/apk/res/android"
            xmlns:app="http://schemas.android.com/apk/res-auto"
            android:layout_width="match_parent"
            android:layout_height="match_parent">
    
       <android.support.v7.widget.RecyclerView
             android:id="@+id/rvToDoList"
             android:layout_width="match_parent"
             android:layout_height="match_parent"/>
    
       <android.support.design.widget.FloatingActionButton
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="bottom|right"
            android:layout_margin="16dp"
            android:src="@mipmap/ic_launcher"
            app:layout_anchor="@id/rvToDoList"
            app:layout_anchorGravity="bottom|right|end"/>
     </android.support.design.widget.CoordinatorLayout>