gpt4 book ai didi

android - 使用 CoordinatorLayout 在滚动时隐藏工具栏

转载 作者:太空狗 更新时间:2023-10-29 14:05:31 26 4
gpt4 key购买 nike

我的应用程序的操作栏由一个 Toolbar 和一个带有 ViewPager 的选项卡 View 组成,用于显示页面内容。我正在使用 CoordinatorLayout,这样我就可以在滚动时隐藏 Toolbar,但它并没有隐藏。这是我的 activity_main.xml:

<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout 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">

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

<android.support.design.widget.AppBarLayout
android:id="@+id/appbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_scrollFlags="scroll|enterAlways">

<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
android:fitsSystemWindows="true"
app:contentInsetEnd="0dp"
app:contentInsetStart="0dp"
app:layout_scrollFlags="scroll|enterAlways">

<include layout="@layout/actionbar" />
</android.support.v7.widget.Toolbar>

<com.whatsgoodly.views.SlidingTabLayout
android:id="@+id/tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/purple"
app:layout_scrollFlags="scroll|enterAlways" />
</android.support.design.widget.AppBarLayout>

<android.support.v4.view.ViewPager
android:id="@+id/pager"
android:layout_width="match_parent"
android:layout_height="0dp”
android:layout_weight="1"
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
</LinearLayout>
</android.support.design.widget.CoordinatorLayout>

有什么想法吗?

最佳答案

将此添加到您的 android.support.v7.widget.Toolbar 标签中:

app:layout_collapseMode="parallax"

关于android - 使用 CoordinatorLayout 在滚动时隐藏工具栏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32662281/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com