I have a BottomSheetDialogFragment which has two buttons in it and when I click on any button dismiss() method is called. Is there a way by which I can animate BottomSheetDialogFragment. I want it to show a slow sliding down animation with a duration of 1000ms.
Sample code
signin.findViewById(R.id.signin_button_using).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
callback.onClickSignInEmail();
dismiss();
}
})
In your fragment which is extended with BottomSheetDialogFragment
, try overriding this method like this
@Override
public void onActivityCreated(Bundle arg0) {
super.onActivityCreated(arg0);
getDialog().getWindow()
.getAttributes().windowAnimations = R.style.DialogAnimation;
}
DialogAnimation can be defined in the styles like this
<style name="DialogAnimation">
<item name="android:windowEnterAnimation">@anim/slide_up</item>
<item name="android:windowExitAnimation">@anim/slide_down</item>
</style>
Further, slide_up and slide_down would be your implementation of required animation. You can find plenty of example for the same online.
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