问题
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.
回答1:
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.
来源:https://stackoverflow.com/questions/39661995/collapsingtoolbar-title-resets-its-position-after-snackbar-appearance