Standard Bottom Sheet with snap to STATE_EXPANDED, STATE_HALF_EXPANDED and STATE_COLLAPSED

34 Views Asked by At

Is it possible to make a Standard Bottom Sheet snap to these three states?

  • STATE_EXPANDED
  • STATE_HALF_EXPANDED
  • STATE_COLLAPSED

By default it already snaps to STATE_EXPANDED and STATE_COLLAPSED but not to STATE_HALF_EXPANDED.

1

There are 1 best solutions below

0
Augusto Carmo On BEST ANSWER

I've just found out how one can achieve it by reading BottomSheetBehavior.java.

If you read that class, you'll find the following snippet of code:

enter image description here

As you can see, the code will only consider snapping to the STATE_HALF_EXPANDED state if fitToContents is equals to false.
So setting this flag to false is the answer to the question.