繁体   English   中英

如何使工具栏隐藏在滚动Android Studio上

[英]How to make toolbar hide on scroll android studio

我试图在向下滚动应用程序时使应用程序上的工具栏消失。 我目前的设置似乎无法弄清楚。 我想知道是否可以通过现在设置工具栏来完成此任务,还是需要重做工具栏?

我尝试添加

app:layout_scrollFlags="scroll|exitUntilCollapsed|snap"

因为有人告诉我放进去,但这似乎行不通。

我的工具栏:

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical">

        <androidx.appcompat.widget.Toolbar
            android:id="@+id/toolbar"
            android:layout_width="match_parent"
            android:layout_height="?attr/actionBarSize"
            android:background="@color/global_color_primary"
            android:elevation="4dp"
            android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
            app:contentScrim="?attr/colorPrimary"
            app:layout_scrollFlags="scroll|exitUntilCollapsed|snap"
            app:popupTheme="@style/ThemeOverlay.AppCompat.Light" />

        <FrameLayout
            android:id="@+id/fragment_container"
            android:layout_width="match_parent"
            android:layout_height="match_parent" />


    </LinearLayout>

工具栏必须是AppBarLayout的子级,才能在滚动时隐藏。 我相信AppBarLayout也必须包含在CoordinatorLayout中。

不久前这个问题的答案有一个很好的工作示例: CoordinatorLayout不会隐藏操作栏

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM