How to do a custom app bar from large title to small with animation?

南楼画角 提交于 2019-12-24 10:49:06

问题


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.


回答1:


Introduce

This is implemented by View: Toolbar and CollapsingToolbarLayout inside AppBarLayout.

Solution

New project -> Choose Scrolling Activity -> Next -> Finish

You will see similar 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>


来源:https://stackoverflow.com/questions/57340137/how-to-do-a-custom-app-bar-from-large-title-to-small-with-animation

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!