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

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

问题描述

我需要知道材料设计库中的CollapsingToolbar何时折叠.

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

推荐答案

更新:由于 23.1.1 + 的支持版本不再存在,因此不需要要使用侦听器并禁用滑动刷新布局,它将按预期运行(链接).

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天全站免登陆