gpt4 book ai didi

android-5.0-lollipop - android Lollipop 工具栏: how to hide/show the toolbar while scrolling?

转载 作者:行者123 更新时间:2023-12-03 05:50:40 27 4
gpt4 key购买 nike

我正在使用 appcompat/support-v7 中引入的新工具栏小部件。我想根据用户是否向上/向下滚动页面来隐藏/显示工具栏,就像在新的 Google Playstore 应用程序或 NewsStand 应用程序中一样。工具栏小部件中是否内置了一些东西,或者我应该将它与 FrameLayout 和 ObservableScrollView 结合使用?

最佳答案

据我所知,没有任何内置功能可以为您做到这一点。不过,您可以查看 Google IO 源代码,尤其是 BaseActivity 。搜索“自动隐藏”或查看 onMainContentScrolled

为了隐藏工具栏,你可以这样做:

toolbar.animate().translationY(-toolbar.getBottom()).setInterpolator(new AccelerateInterpolator()).start();

如果您想再次显示它,请调用:

toolbar.animate().translationY(0).setInterpolator(new DecelerateInterpolator()).start();

关于android-5.0-lollipop - android Lollipop 工具栏: how to hide/show the toolbar while scrolling?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26539623/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com