1:CoordinatorLayout is a normal ViewGroup whose layout characteristics are similar to FrameLayout. 2:CoordinatorLayout is super FrameLayout, which is more powerful than FrameLayout because it can interact with Behavior. 3:CoordinatorLayout and Behavior complement each other, they build a wonderful interactive system together. There are two purposes for the custom Behavior: 1. Determine the dependency relationship between a View and another View. 2 Specifies a View that responds to nested sliding events. 5: There are two ways to determine the dependency of two Views. One is that layoutDepentOn() in Behavior returns true. The other option is to anchor a View directly through XML. The onDependentViewChanged method in the Behavior is called when the size and position of the dependent party change. If you change the size or position of the view that you actively depend on in this method, return true at the end of the method. 6: Nested scroll and fling are classified into nested scroll and fling. Whether the corresponding View in the Behavior accepts the response is determined by the onStartNestedScroll() return value. In general, onNestedPreScroll() processes the corresponding nested scroll response and onPreFling processes the fling event. But this is not absolute, according to the actual situation. NestedScrollView can generate nested sliding events because it is essentially a NestedScrollingChild object, The CoordinatorLayout responds because it is essentially a NestedScrollingParent object. 8. Behavior is a plug-in mechanism. If there is no Behavior, CoordinatorLayout is no different from FrameLayout. The existence of Behavior can determine the measurement size, layout position and touch response of the corresponding ChildView in CoordinatorLayout.

Finally, go back to the beginning of the article. We have been familiar with CoordinatorLayout, NestedScrollView also know a little bit. We don’t know anything about AppbarLayout. But the panic doesn’t exist anymore, because knowing the mechanism of Behavior, we can know that CoordinatorLayout doesn’t have to work with AppBarLayout or FloatButton, it’s independent, put them aside, We can also achieve very dazzling interaction effects by customizing behaviors.

See the following links for details:

Blog.csdn.net/briblue/art…

Two problems encountered in using CoordinatorLayout are linked:

Juejin. Cn/post / 684490…

TAB slide top link: juejin.cn/post/684490…