I noticed that by default, when a bottom sheet dialog is shown, the scrim just pop up without any animation, which is not a good user experience. So I was wondering how to show the scrim with animation. Any suggestion?
Asked
Active
Viewed 766 times
1 Answers
0
You can use
getDialog().getWindow().getAttributes().windowAnimations = *Your animation here*
(
For example, R.style.myAnimation
<style name="myAnimation">
<item name="android:windowEnterAnimation">@anim/up</item>
<item name="android:windowExitAnimation">@anim/down</item>
</style>
)

Huseynbaba
- 70
- 10
-
I tried to define my custom `enter/exit` animation for the scrim and used it in the `onCreate` method of my `bottomSheetDialogFragment`:`dialog?.window?.attributes?.windowAnimations = R.style.scrimAnimation`. As it turned out, the scrim is now not popping up suddenly but is still not working as expected. For example, even if the animation duration is given the value `3000ms`, the actual duration is obviously less than`3000`. – Fever Jun 22 '22 at 04:15