Android support,

Android support, CoordinatorLayout is a layout container in Android Support Library, which is designed to coordinate the interaction between sub -views.It provides a simple and flexible way to manage interaction between sub -views and can automatically handle various complex animation effects and layout behaviors in the user interface. The following will share some experiences and skills to use CoordinatorLayout, and provide some Java code examples to help better understand. 1. Use coordinatorLayout for coordination between views CoordinatorLayout can be used to manage coordinated operations between sub -views.For example, there is a floatingActionButton suspension button on the interface and a SnackBar prompt box. When SnackBar pops out, you can use CoordinatorLayout to coordinate the position of FlolationActionButton to ensure that it is not covered by SnackBar. First, the coordinatorLayout needs to be used as the root container in the layout file.Then, add the corresponding Behavior to the view that needs to be coordinated to tell how to coordinate between the CoordinatorLayout view.For example, for FloatingActionButton, you can use FlolationActionButton.behavior to achieve coordination with SnackBar. Example code: <android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="match_parent"> <android.support.design.widget.FloatingActionButton android:id="@+id/fab" android:layout_width="wrap_content" android:layout_height="wrap_content" app:layout_behavior="android.support.design.widget.FloatingActionButton.Behavior" app:layout_anchor="@id/snackbar" app:layout_anchorGravity="top|right|end" /> <android.support.design.widget.Snackbar android:id="@+id/snackbar" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Snackbar Example" /> </android.support.design.widget.CoordinatorLayout> 2. Use coordinatorLayout to achieve various animation effects CoordinatorLayout can achieve various animation effects by adding different Behavior.For example, you can use AppBarlayout.behavior to achieve the interaction effect between Toolbar and RecyclerView. When the RecyclerView rolled, Toolbar can gradually hide or display. Example code: <android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="match_parent"> <android.support.design.widget.AppBarLayout android:id="@+id/appbar" android:layout_width="match_parent" android:layout_height="wrap_content" android:theme="@style/AppTheme.AppBarOverlay"> <android.support.v7.widget.Toolbar android:id="@+id/toolbar" android:layout_width="match_parent" android:layout_height="?attr/actionBarSize" android:background="?attr/colorPrimary" app:layout_scrollFlags="scroll|enterAlways" /> </android.support.design.widget.AppBarLayout> <android.support.v7.widget.RecyclerView android:id="@+id/recyclerView" android:layout_width="match_parent" android:layout_height="match_parent" app:layout_behavior="@string/appbar_scrolling_view_behavior" /> </android.support.design.widget.CoordinatorLayout> 3. Custom Behavior to achieve specific layout behavior If you need to implement some special layout, you can also customize Behavior.By inheriting the CoordinatorLayout.behavior class and rewrite the corresponding method, you can achieve the layout effect you want. Example code: public class CustomBehavior extends CoordinatorLayout.Behavior<View> { @Override public boolean layoutDependsOn(CoordinatorLayout parent, View child, View dependency) { // Specify dependency as a dependent view return dependency instanceof SomeView; } @Override public boolean onDependentViewChanged(CoordinatorLayout parent, View child, View dependency) { // Treat the location or animation of the child when changing the location of the dependency return true; } } The above are some sharing of the experience and skills of Android support library coordinatorLayout.By using CoordinatorLayout, we can achieve complex view interaction and animation effects, and can better manage layout behaviors.I hope these content can help you!