I have tried the new BottomSheetBehaviour
with design library 23.0.2 but i think it too limited. When I change state with setState()
method, the bottomsheet use ad animation to move to the new state.
How can I change state immediately, without animation? I don't see a public method to do that.
Unfortunately it looks like you can't. Invocation of BottomSheetBehavior
's setState
ends with synchronous or asynchronous call of startSettlingAnimation(child, state)
. And there is no way to override these methods behavior cause setState
is final and startSettlingAnimation
has package visible modifier. Check the sources for more information.
I have problems with the same, but in a bit different way - my UI state changes setHideable
to false before that settling animation invokes, so I'm getting IllegalStateException
there. I will consider usage of BottomSheetCallback
to manage this properly.
If you want to remove the show/close animation you can use dialog.window?.setWindowAnimations(-1)
. For instance:
class MyDialog(): BottomSheetDialogFragment() {
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
val dialog = super.onCreateDialog(savedInstanceState)
dialog.window?.setDimAmount(0f) // for removing the dimm
dialog.window?.setWindowAnimations(-1) // for removing the animation
return dialog
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With