(折叠)工具栏标题在Snackbar出现后重置其位置 [英] (Collapsing)Toolbar title resets its position after Snackbar appearance
问题描述
我有一个以CollapsingToolbarLayout
和CoordinatorLayout
为根元素的布局.
每当activity
中显示Snackbar
时,即使toolbar
没有(完全)展开,toolbar
的title
也会将其位置重置为CollapsingToolbar
的默认扩展标题位置.>
第二张图片显示title
是固定的,无论toolbar
是否扩展.
当我在activity
或fragment
中调用snackbar.show()
时,结果是相同的.
我的布局结构如下:
<CoordinatorLayout>
<AppBarLayout>
<CollapsingToolbarLayout>
<Toolbar />
<TabLayout />
</CollapsingToolbarLayout>
</AppBarLayout>
<ViewPager />
<FloatingActionButton />
我对appcompat and design library (v24.2.1)
使用最新的依赖项.
我希望有足够的信息,并且有人对如何解决这个问题有所了解:P
同样在模板中,当您启动一个新项目并选择Scrolling activity
时,调用snackbar.show()
时也会出现相同的问题.因此,这是一个图书馆问题.
我遇到了同样的问题,这是一个库问题.在最新版本的设计支持库(25.0.0)已修复.在build.gradle上使用以下内容:
compile 'com.android.support:design:25.0.0'
希望这会有所帮助.
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.
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.
这篇关于(折叠)工具栏标题在Snackbar出现后重置其位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!