Other major usage examples of coordinatorlayout include the App Bar (formerly Action Bar) and scrolling technology. You may have already used toolbar in the Layout, toolbar allows you to easily customize the appearance and integration of the icon parts and layouts in your app. The design package goes further at this point: Using Appbarlayout allows toolbar and other views (such as tablayout to provide tab) to generate feedback on scrolling events in the sibling view labeled Scrollingviewbehavior. As a result, you can create layouts like this:
1<Android.support.design.widget.CoordinatorLayout2 xmlns:android= ' http://schemas.android.com/apk/res/android '3 Xmlns:app= ' Http://schemas.android.com/apk/res-auto '4 Android:layout_width= ' match_parent '5 Android:layout_height= ' match_parent '>6 7<!-- Your scrollable View-->8<Android.support.v7.widget.RecyclerView9 Android:layout_width= ' match_parent 'Ten Android:layout_height= ' match_parent 'App:layout_behavior= ' @string/appbar_scrolling_view_behavior ' /> the<Android.support.design.widget.AppBarLayoutAndroid:layout_width= ' match_parent 'Android:layout_height= ' wrap_content '> -<Android.support.v7.widget.Toolbar17 ... App:layout_scrollflags= ' Scroll|enteralways '> About<Android.support.design.widget.TabLayout21 ... App:layout_scrollflags= ' Scroll|enteralways '> at</Android.support.design.widget.AppBarLayout> -</Android.support.design.widget.CoordinatorLayout>
Now, when users use Recyclerview, Appbarlayout is able to respond to events that control how they roll in and out of the screen by using the scroll labels of the child views. These tags include:
Scroll: This tag should be a collection of all views that you want to roll out of the screen-for those views that do not use this tag, they are set at the top of the screen. Enteralways: This tab ensures that any downward swipe will make this view visible, activating the "Quick return" mode. Exituntilcollapsed: This tag causes the view not to scroll out unless the view becomes "collapsed" (its minheight) before exiting.
Note: All views that use the scroll tag must be declared before the view is used without the label. This will ensure that all views exit from the top while the fixed elements fall.
Material Design (ix)--coordinatorlayout and app Bar