I have a layout with CollapsingToolbarLayout
and CoordinatorLayout
as root element.
Whenever a Snackbar
is shown in the activity
the title
of the toolbar
resets its position to the default expanded title position of the CollapsingToolbar
even if the toolbar
is not (fully) expanded.
The second picture shows that the title
is fixed no matter if the toolbar
expands or not.
The result is the same when I call snackbar.show()
in activity
or fragment
.
My layout structure looks like this:
<CoordinatorLayout>
<AppBarLayout>
<CollapsingToolbarLayout>
<Toolbar />
<TabLayout />
</CollapsingToolbarLayout>
</AppBarLayout>
<ViewPager />
<FloatingActionButton />
I use the latest dependencies for appcompat and design library (v24.2.1)
.
I hope that's enough information and somebody has an idea how to solve the issue :P
EDIT:
Also in the template when you start a new project and choose Scrolling activity
the same problem appears when snackbar.show()
is called. So it's a library issue.
Use mAppBarLayout. setExpanded(true) to expand Toolbar and use mAppBarLayout. setExpanded(false) to collapse Toolbar.
In addition to pinning a view, you can use app:layout_collapseMode="parallax" (and optionally app:layout_collapseParallaxMultiplier="0.7" to set the parallax multiplier) to implement parallax scrolling (say of a sibling ImageView within the CollapsingToolbarLayout ).
I was having the same problem and it was a library issue. On the latest version of design support library (25.0.0) is fixed. Use the following on your build.gradle:
compile 'com.android.support:design:25.0.0'
Hope this helps.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With