如何实现向下滚动以隐藏Playstore app等操作栏?

时间:2016-03-01 06:36:16

标签: java android android-actionbar

如何实施向下滚动以隐藏播放商店应用程序等操作栏? 任何参考项目(github或任何)或提示?

这是我的基本活动代码,它同时包含操作栏和片段。

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

    </FrameLayout>
</RelativeLayout>

1 个答案:

答案 0 :(得分:-1)

尝试使用协调员布局

CoordinatorLayout扩展了完成许多Google Material Design滚动效果的功能。目前,此框架中提供了多种方法,使其无需编写您自己的自定义动画代码即可工作。

有关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>