概观
我正在尝试实现材料设计中描述的具有重叠内容的Scrolling Techniques灵活空间之一.
Flexible space with overlapping content
Content can overlap the app bar.
Behavior:
The app bar’s starting position should be located behind the content.
Upon upward scroll, the app bar should scroll faster than the content,
until the content no longer overlaps it. Once anchored in place, the
app bar lifts up to allow content to scroll underneath.
07001
问题
但问题是,
我的AppBar中的标题在展开时向下滚动并隐藏在重叠内容下方.
在这里,我的工具栏隐藏在重叠的CardView下方.
折叠appbar时,工具栏以及标题从下方向上滑动.
码
这是我的代码:
活动的main.xml中
...
android:layout_width="match_parent"
android:layout_height="match_parent">
android:layout_width="match_parent"
android:layout_height="200dp"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">
...
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_scrollFlags="scroll|exitUntilCollapsed">
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:layout_gravity="top"
android:background="?attr/colorPrimary"
app:layout_collapseMode="pin"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" />
android:layout_width="match_parent"
android:layout_height="match_parent"
...
我还在MainActivity的onCreate函数中添加了这些
setSupportActionBar(toolbar);
collapsingToolbarLayout.setTitle("App Name");
我希望工具栏(包含瓷砖和其他内容,稍后我将添加)保持在顶部,而不管appbar是否被展开或折叠.
我已经阅读了这些文档,经历了很多帖子和教程,观看了很多视频但却未能找到可行的解决方案或任何相关的解决方案.
如果有人对如何解决这个问题有所了解,请建议.谢谢你的帮助.