I have a bottom sheet with a NestedScrollView inside (see below). When I press on a FAB button, I want to make some parts in this NestedScrollView invisible. But when I chan
The BottomSheetBehavior has its own behavior by which you can get respective results. The following are the behavior of the bottomsheet.
STATE_DRAGGING, STATE_SETTLING, STATE_EXPANDED, STATE_COLLAPSED, STATE_HIDDEN.
Don't use visibility of any layouts.
Use this behavior in your code like:
fab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
int behaviorState = bottomSheetBehavior.getState();
if (behaviorState == BottomSheetBehavior.STATE_EXPANDED) {
bottomSheetBehavior.setState(BottomSheetBehavior.STATE_COLLAPSED);
} else {
bottomSheetBehavior.setState(BottomSheetBehavior.STATE_EXPANDED);
}
}
});