Why Dialog animation duration not working

Viewed 39

I want to use custom animation on dialog but duration is not working

Dialog

class GiftDialog(context: Context) : Dialog(context, R.style.AppMaskStatusTheme) {

    private val viewBinding: DialogGiftBinding by lazy { DialogGiftBinding.inflate(LayoutInflater.from(context)) }

    init {
        setContentView(viewBinding.root)
        window?.let {
            it.setBackgroundDrawableResource(R.color.transparent)
            it.setLayout(WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.MATCH_PARENT)
            it.setWindowAnimations(R.style.DialogAnimation)
        }
    }
}

style


    <style name="DialogAnimation">
        <item name="android:windowEnterAnimation">@anim/slide_bottom_to_top</item>
        <item name="android:windowExitAnimation">@anim/slide_top_to_bottom</item>
    </style>

    <style name="AppMaskStatusTheme" parent="Theme.AppCompat.Light">
        <item name="android:statusBarColor">@color/dark</item>
    </style>

slide_bottom_to_top

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
    <translate
        android:duration="1000"//It doesn't work what I change
        android:fromYDelta="0%p"
        android:toYDelta="100%p" />
</set>

slide_top_to_bottom

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
    <translate
        android:duration="1000"//It doesn't work what I change
        android:fromYDelta="100%"
        android:toXDelta="0" />
</set>
0 Answers
Related