Open Mugurell opened 3 years ago
I would also like this feature very much.
I do also have this problem!
eager to have this too
Please add this
Just to let you all know, you can replicate something similar by using this class:
class SkipHalfExpandedBottomSheetBehavior<V: View> : BottomSheetBehavior<V> {
constructor() : super()
constructor(context: Context, attributeSet: AttributeSet?) : super(context, attributeSet)
init {
isFitToContents = false
}
override fun shouldSkipHalfExpandedStateWhenDragging() = true
override fun shouldExpandOnUpwardDrag(
dragDurationMillis: Long,
yPositionPercentage: Float
) = true
}
I don't understand why app:behavior_fitToContents="false" allow us to drag to STATE_HALF_EXPANDED (app:behavior_fitToContents="true" doesn't allow us to drag to STATE_HALF_EXPANDED). The problem is big (https://github.com/material-components/material-components-android/issues/2702, https://github.com/material-components/material-components-android/issues/3018). I would like a convenience method to set the collapsed bottom sheet height to half the height of the screen and provide access to its top actions (https://m2.material.io/components/sheets-bottom > Modal bottom sheet > Behavior > Visibility, https://developer.android.com/reference/com/google/android/material/bottomsheet/BottomSheetBehavior#setPeekHeight(int)).
Most of the existing issues revolve around half-expanded state, collapse state and fit-to-contents. At this point, I believe the BottomSheetBehavior
design should contain or address the following issues:
fitToContents = false
(currently floats to the top which effectively made it an experimental API rather than a stable one)findScrollingChild
might be preferred.All these issues look separate but they're actually part of the same problem. And these changes could be made without altering the existing API/behaviour.
100% agree @MuntashirAkon. BottomSheetBehavior
is honestly one of the most neglected parts of MDC. I really hope that Jetpack Compose will one day provide a proper bottom sheet scaffold with a saner API and far less workarounds to get non-trivial functionality working, but I'm not holding my breath.
Is your feature request related to a problem? Please describe. By popular request - https://stackoverflow.com/questions/59487982/android-how-to-disable-state-half-expanded-state-of-a-bottom-sheet:
behavior_fitToContents = false
to try getting the view to have 2 possible states: expanded and collapsed with app defined fixed dimensions.STATE_HALF_EXPANDED
state and view height is introduced that's of no use.Describe the solution you'd like A
behavior_skipHalfExpanded
property/method that would have the behavior never setSTATE_HALF_EXPANDED
.We also happily accept pull requests.