The app I\'m working on consists of a Navigation Drawer which is implemented in an Activity. The activity layout is as follows:
As document said
AppBarLayout supports
void setExpanded (boolean expanded, boolean animate);
Sets whether this AppBarLayout is expanded or not.
- expanded boolean: true if the layout should be fully expanded, false if it should be fully collapsed
- animate boolean: Whether to animate to the new state
So first, you need
AppBarLayout appBarLayout = findViewById(R.id.appBarLayout);
then to expand layout
appBarLayout.setExpanded(true, true); // with animation
appBarLayout.setExpanded(true, false); // without animation
and to collapse layout
appBarLayout.setExpanded(false, true); // with animation
appBarLayout.setExpanded(false, false); // without animation