android - 向上滚动时显示工具栏 - 具有多个捕捉点的 CoordinatorLayout
问题描述
我正在使用这种技术在折叠工具栏上创建多个捕捉点(我使用相同的布局和代码)
但我的问题是当用户在 recyclerview 中间向上滚动时如何显示工具栏
目前,如果用户到达顶部,它首先显示工具栏,然后展开折叠工具栏
但是我想在用户在 recyclerview 中间向上滚动时(在到达顶部之前)显示工具栏,之后,如果用户到达顶部,我想展开折叠布局。
我怎样才能修改那个答案来实现呢?
目前它看起来像这样。如果用户到达顶部,我只想在用户向上滚动时显示工具栏我想显示所有折叠的工具栏
我的 AppBarLayout
<com.google.android.material.appbar.AppBarLayout
android:id="@+id/app_bar_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
android:background="@color/colorPrimary"
app:elevation="0dp"
android:elevation="0dp">
<com.google.android.material.appbar.CollapsingToolbarLayout
android:id="@+id/collapsing_toolbar"
android:layout_width="match_parent"
android:layout_height="200dp"
app:layout_scrollFlags="scroll|snap"
app:contentScrim="?attr/colorPrimary"
app:expandedTitleMarginStart="@dimen/app_bar_expanded_title_margin_start">
<LinearLayout
android:id="@+id/expanded_layout"
android:visibility="visible"
android:layout_width="match_parent"
android:layout_height="200dp"
android:layout_marginBottom="?attr/actionBarSize"
android:orientation="vertical">
</LinearLayout>
</com.google.android.material.appbar.CollapsingToolbarLayout>
<androidx.appcompat.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="90dp"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
android:layout_gravity="bottom"
app:layout_collapseMode="pin"
android:contentInsetLeft="0dp"
android:contentInsetStart="0dp"
app:contentInsetLeft="0dp"
app:contentInsetStart="0dp"
android:contentInsetRight="0dp"
android:contentInsetEnd="0dp"
app:contentInsetRight="0dp"
app:contentInsetEnd="0dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
...
</LinearLayout>
</androidx.appcompat.widget.Toolbar>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="?actionBarSize"
android:layout_marginStart="@dimen/general_margin"
android:orientation="horizontal">
<CustomTabLayout
android:id="@+id/tab_layout"
android:layout_width="match_parent"
android:layout_height="@dimen/discover_tab_height"
android:background="@color/colorPrimary"
android:paddingEnd="@dimen/general_margin"
android:layout_gravity="center"
android:clipToPadding="false"
app:tabMode="scrollable"
app:tabGravity="fill"
app:tabBackground="@drawable/discover_tab_selector"
android:elevation="@dimen/tab_layout_elevation"
app:tabSelectedTextColor="@color/colorPrimary"
app:tabTextColor="@color/colorAccentPassive"
app:tabRippleColor="@null"
app:tabIndicatorHeight="0dp"
app:tabMinWidth="30dp"
app:tabIndicatorColor="@color/transparent"
app:tabTextAppearance="@style/DiscoverTabTextAppearance"/>
</LinearLayout>
</com.google.android.material.appbar.AppBarLayout>
请检查 具有多个捕捉点的链接 CoordinatorLayout
谢谢你,对不起我的英语。
解决方案
推荐阅读
- python - python-2.7.12 和 python-3.5.2 中生成器的不同行为
- java - 使用 volley 发出请求时没有得到响应
- c# - 如何使用 C# 从 Active Directory 获取所有电子邮件列表?
- django - 无法部署到弹性 beantalk
- javascript - 如何检查 JavaScript 中布尔 HTML 属性的当前值?
- python - 如何从python列表中只删除零位?
- c - 我们可以在结构定义之前在文件范围内声明结构对象吗?
- django - 如何在 django 中编辑模板时显示选中的项目和上传的图像值
- javafx - 如何在 javafx 中打开带有标签、文本字段等的新窗口?
- wordpress - 如何将占位符图标放入联系表格 7?