Hacking Event Collapsing Toolbar Android

0

Is there any way to identify the CollapsingToolbar collapsing event?

Type an onChangeCollapsingListener

What I need to do is to set the visibility of some screen components when CollapsingToolbar gives an expand or a collapsing.

Thank you in advance.

    
asked by anonymous 27.01.2016 / 21:41

1 answer

1

The AppBarLayout has a listener to be notified of changes of offset .

I believe it is possible to be notified when it is completely collapsed or expanded as follows:

AppBarLayout.OnOffsetChangedListener  listener = new AppBarLayout.OnOffsetChangedListener() {
    @Override
    public void onOffsetChanged(AppBarLayout appBarLayout, int verticalOffset) {
        if(collapsingToolbar.getHeight() + verticalOffset < 2 * ViewCompat.getMinimumHeight(collapsingToolbar)) {
            // CollapsingToolbar esta colapsado
        } else {
            // CollapsingToolbar esta expandindo
        }
    }
};

appBar.addOnOffsetChangedListener(listener);

Source: link

    
27.01.2016 / 22:46