What you're looking for is CollapsingToolbarLayout .
The general approach to this kind of animations is to use top level CoordinatorLayout which contain two children: the first child is the "collapsible" content, and the second is "body". The general hierarchy looks like this:
CoordinatorLayout
|-AppBarLayout
|-CollapsingToolbarLayout
|-Toolbar
|-ScrollView
The second child must not be ScrollView
- use any ViewGroup
that suits your needs, and just add the following attribute to its description in xml
:
app:layout_behavior="@string/appbar_scrolling_view_behavior"
the above string resource should map to AppBarLayout.ScrollingViewBehavior (just use android.support.design.widget.AppBarLayout$ScrollingViewBehavior
as this resource's value).
There is very good tutorial on this kind of animations on Codepath .
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.