android - How to do a custom app bar from large title to small with animation?
问题描述
I means this:
The transition occurs as the content on the layer begin to scroll.
It's similarly to prominent
from material.io. But I don't know how to do it. I could not find an example.
解决方案
介绍
这是由View
:Toolbar
和CollapsingToolbarLayout
inside实现的AppBarLayout
。
解决方案
新建项目 -> 选择Scrolling Activity
-> 下一步 -> 完成
你会看到类似的activity_main.xml
<com.google.android.material.appbar.AppBarLayout
android:id="@+id/app_bar"
android:layout_width="match_parent"
android:layout_height="@dimen/app_bar_height"
android:fitsSystemWindows="true">
<com.google.android.material.appbar.CollapsingToolbarLayout
android:id="@+id/toolbar_layout"
style="@style/ToolbarTextAppearanceStyle"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
app:layout_scrollFlags="scroll|exitUntilCollapsed"
app:toolbarId="@+id/toolbar">
<androidx.appcompat.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:layout_collapseMode="pin" />
</com.google.android.material.appbar.CollapsingToolbarLayout>
</com.google.android.material.appbar.AppBarLayout>
推荐阅读
- d3.js - 地图未渲染,但数据正确
- sql - 在 R 中使用 json 文件读取数据帧
- sql - 使用休眠创建接受多个空值的唯一索引
- java - 在 android studio 中找不到符号错误
- javascript - 在服务中可观察与仅使用 this.service Angular 7
- r - 无法在 tidytext 中使用 NRC 词典。match.arg(lexicon) 中的错误:“arg”应该是“afinn”、“bing”、“loughran”之一
- java - 带有 Elasticsearch 6.4.2 的 Spring 数据不适用于 Java hashmap 属性
- mysql - SQL SERVER 通过字段之间的数学运算排序
- c++ - 在类中存储指向 sqlite3 数据库的指针会引发段错误
- python - 抽象方法:如何使代码在类定义上失败,而不是实例创建?