0

This link! show me how to disable the collapsing tool bar layout. The behavior I want is to collapse and disable the collapsing tool bar and show the error view when there is no internet connection. So How can I do the trick , collapsing and disabling the collapsing tool bar layout?

Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
Daniel Jr McCoy
  • 157
  • 1
  • 15

1 Answers1

0

I got the answer from here https://stackoverflow.com/a/40267244/10045201

public void disableAppBar(AppBarLayout appBarLayout) {
    if (appBarLayout.getLayoutParams() != null) {
        CoordinatorLayout.LayoutParams layoutParams = (CoordinatorLayout.LayoutParams)appBarLayout.getLayoutParams();
        AppBarLayout.Behavior appBarLayoutBehaviour = new AppBarLayout.Behavior();
        appBarLayoutBehaviour.setDragCallback(new AppBarLayout.Behavior.DragCallback() {
            @Override
            public boolean canDrag(@NonNull AppBarLayout appBarLayout) {
                return false;
            }
        });
        layoutParams.setBehavior(appBarLayoutBehaviour);
    }
}
Padmal
  • 458
  • 5
  • 15
Daniel Jr McCoy
  • 157
  • 1
  • 15