android - 更改 AppBarLayout 的 totalScrollRange
问题描述
如何更改 AppBarLayout 的 totalScrollChange ,使其滚动自定义范围,而不是使用滚动标志测量子项的高度。
对于下面的示例,我们的想法是能够仅滚动工具栏的一半 (100dp) 而不是其整个高度 (200dp),因此当我继续滚动时,另一半始终保持可见。
<androidx.coordinatorlayout.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">
<com.google.android.material.appbar.AppBarLayout
android:id="@+id/appbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">
<androidx.appcompat.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="200dp"
android:background="?attr/colorPrimary"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
app:layout_scrollFlags="scroll|exitUntilCollapsed" />
<com.google.android.material.tabs.TabLayout
android:id="@+id/tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</com.google.android.material.appbar.AppBarLayout>
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recyclerview"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior"/>
</androidx.coordinatorlayout.widget.CoordinatorLayout>
谢谢!
解决方案
推荐阅读
- typo3 - 如何在“点击放大模式”(css-styled-content)中避免图像渲染超过原始图像大小
- flutter - 如何在 Flutter 中构建静态 datePicker 小部件,无需在之前按下按钮
- javascript - 如何正确指向滑块#
- python - Python 3.6 如果 xpath 不存在,我如何对 xpath('@item').get() 使用 ELSE 或 DEFAULT 语句
- html - 为什么网格不留下标有“。”的单元格 空的?
- javascript - Google 表格脚本函数 UrlFetchApp.fetch 不能从 .onEdit(e) 运行,但可以从编辑器运行
- keras - 如何创建一个自动编码器,其中编码器的每一层都应与解码器的一层表示相同
- flutter - Flutter - 在底部导航栏中发送参数
- javascript - Angular,如何在多个页面中而不是在一个大列表中显示 *ngFor
- javascript - 在使用 jQuery UI 表单完成 AJAX 调用之前重新加载页面