(折叠)工具栏标题在Snackbar出现后重置其位置 [英] (Collapsing)Toolbar title resets its position after Snackbar appearance

本文介绍了(折叠)工具栏标题在Snackbar出现后重置其位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个以CollapsingToolbarLayoutCoordinatorLayout为根元素的布局. 每当activity中显示Snackbar时,即使toolbar没有(完全)展开,toolbartitle也会将其位置重置为CollapsingToolbar的默认扩展标题位置.

第二张图片显示title是固定的,无论toolbar是否扩展.

当我在activityfragment中调用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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆