0

I have a custom DialogFragment

class CompactPickerFragment : DialogFragment()

By default it fades in, I want to make it slide in from the bottom.

I have tried the following things (all except one found on stack overflow):

First define a style like:

<style name="DialogTheme" parent="Some parent, I've tried different parents here"> //
    <item name="android:windowEnterAnimation">@anim/slide_in_left</item>
    <item name="android:windowExitAnimation">@anim/slide_out_right</item>
</style>

The slide animations work in other parts of the app when sliding fragment. Set this theme in various ways:

class CompactPickerFragment : DialogFragment() {

    // Attempt 1
    override fun getTheme() = R.style.DialogTheme

   // Attempt 2
    override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {         
       val builder = AlertDialog.Builder(activity!!, R.style.DialogTheme)
        return builder.create()
   }

    // Attempt 3
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setStyle(STYLE_NO_FRAME, R.style.DialogTheme)

These attempts roughylu all gave this 'without changes'-'with changes' picture(and no animation happens):

beforeafter

And I also tried setting a enter transistion, but havn't managed to get that to do anything:

private fun ShowPicker() {
    val slide = Slide()
    slide.duration = 1000
    slide.slideEdge = Gravity.BOTTOM
    slide.mode = MODE_IN
    val dialog = CompactPickerFragment.newOperandInstance()
    dialog.enterTransition = slide
    dialog.show(fragmentManager, CompactPickerFragment.TAG)
}

How do you supply a transition/animation to a custom dialog fragment?

Adam
  • 2,845
  • 2
  • 32
  • 46

1 Answers1

0

You should try this show-dialogfragment-with-animation-growing-from-a-point

Arjun Vyas
  • 409
  • 5
  • 14