Fragment transaction breaks layout if exitUntilCollapsed flag is set
See original GitHub issueDescription: The pretty much standard layout of
CoordinatorLayout
AppBarLayout
CollapsingToolbarLayout [app:layout_scrollFlags="scroll|snap|exitUntilCollapsed"]
Toolbar
NestedScrollView [app:layout_behavior="@string/appbar_scrolling_view_behavior"]
in fragment works pretty well until fragment transaction happens (e.g. switch to another fragment and come back).
With no exitUntilCollapsed
flag set original fragment got restored as it should keeping the scroll position etc. But if this flag is set various issues happen after the fragment transaction including scroll position reset (sometimes) and (pretty much always) inability to move scrolled content (including overscroll effect) to the view port.
Removal of exitUntilCollapsed
flag makes the whole thing work again but at the price of Toolbar visibility.
Android API version: 23
Material Library version: master branch
Device: LG G3
Demo: After I’ve switched to another fragment and came back the part of content (“Transitions” label, overscroll etc) became unavailable:
Issue Analytics
- State:
- Created 4 years ago
- Reactions:7
- Comments:7
Top GitHub Comments
I don’t believe this issue has been fixed yet. I am using the layout below:
and let’s say the toolbar is in collapsed state, and user has scrolled somewhere in the list, taps a list item and navigates to another fragment. Hitting back, the fragment transaction is reversed, and upon returning to this fragment, the collapsing toolbar is in expanded state but scroll pos in recycler view has been retained. it almost looks like the Collapsing toolbar expands as the fragment is exiting, so when returning to it, it’s now in expanded state.
I tested with version
1.3.0-rc01
which was tagged above as having a commit that fixes this issue.Fixed by https://github.com/material-components/material-components-android/commit/a21a30026a33fc20cf7ad699d32d1298b84096c6