如何确定 CollapsingToolbar 已折叠? [英] How can I determine that CollapsingToolbar is collapsed?

查看:21
本文介绍了如何确定 CollapsingToolbar 已折叠?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要知道 Material Design 库中的 CollapsingToolbar 何时折叠.

I need to know when CollapsingToolbar from material design library is collapsed.

推荐答案

UPDATE: 由于支持 23.1.1+ 的版本问题不再存在,不需要要使用侦听器并禁用滑动刷新布局,它将正常工作(link).

UPDATE: Since support versions of 23.1.1+ the issue is no longer there, no need to use the listener and disable the swipe refresh layout, it will work as it should (link).

在您的 AppBarLayout

AppBarLayout appBarLayout = (AppBarLayout) view.findViewById(R.id.app_bar_layout);
appBarLayout.addOnOffsetChangedListener(this);

并检查 offset 是否为 0,表示工具栏已完全展开.

And check if offset is 0, meaning the toolbar is fully expanded.

@Override
public void onOffsetChanged(AppBarLayout appBarLayout, int offset)
{
    if (offset == 0)
    {
        // Fully expanded
    }
    else
    {
        // Not fully expanded or collapsed
    }
}

这篇关于如何确定 CollapsingToolbar 已折叠?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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