(Collapsing)Toolbar title resets its position after Snackbar appearance

谁都会走 提交于 2019-12-09 18:14:01

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!