Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I determine that CollapsingToolbar is collapsed?

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

like image 764
d0pestar Avatar asked Aug 07 '15 08:08

d0pestar


People also ask

How do you collapse a CollapsingToolbarLayout?

Use mAppBarLayout. setExpanded(true) to expand Toolbar and use mAppBarLayout. setExpanded(false) to collapse Toolbar.

What is collapsing Toolbar Android?

Android CollapsingToolbarLayout is a wrapper for Toolbar which implements a collapsing app bar. It is designed to be used as a direct child of a AppBarLayout. This type of layout is commonly seen in the Profile Screen of the Whatsapp Application.

How to set title in collapsing Toolbar?

collapsingToolbarLayout. setTitleEnabled(false); toolbar. setTitle("My Title"); By calling setTitleEnabled(false); , the title appeared in the toolbar.


1 Answers

As Marko said, this can be achieved using your own implementation of a OnOffsetChangedListener.

AppBarLayout appBarLayout = (AppBarLayout) view.findViewById(R.id.app_bar_layout); appBarLayout.addOnOffsetChangedListener(new AppBarLayout.OnOffsetChangedListener() {         @Override         public void onOffsetChanged(AppBarLayout appBarLayout, int verticalOffset) {             if (Math.abs(verticalOffset) == appBarLayout.getTotalScrollRange()) {                 // Collapsed             } else if (verticalOffset == 0) {                 // Expanded             } else {                 // Somewhere in between             }         }     });); 
like image 147
chrlaura Avatar answered Oct 07 '22 01:10

chrlaura