I have an activity with XML.
Something like:
How can I sync scroll of these 2 AppBarLayouts so that the outer appbar collapses either before/after (doesn't matter if it happens before or after) the inside appbar collapses?
Delete that Fragment's CoordinatorLayout and just use RelativeLayout as a root tag (for Fragment)and then do your stuffs with that ViewPager in the MainActivity.
For example, use it inside that CoordinatorLayout like this:
Github example:
https://github.com/TheLittleNaruto/SupportDesignExample
Or perhaps you want to scroll that ViewPager inside the NestedScrollView but, you'll face a problem then use the following code inside it:
app:layout_behavior="@string/appbar_scrolling_view_behavior"
That's pretty much it.
A fragment of the ViewPager has a CoordinatorLayout and AppBarLayout+CollapsingToolbarLayout. XML:
You don't need to use them twice.