I need to know when CollapsingToolbar from material design library is collapsed.
Use mAppBarLayout. setExpanded(true) to expand Toolbar and use mAppBarLayout. setExpanded(false) to collapse Toolbar.
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.
collapsingToolbarLayout. setTitleEnabled(false); toolbar. setTitle("My Title"); By calling setTitleEnabled(false); , the title appeared in the toolbar.
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 } } }););
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With