2

I have a DialogFragment that asking user to input a password. When user enter at most 4 digits, I want to shake the DialogFragment (just like MacOS login dialog does).

I try to shake it by starting an animation on DialogFragment.getView() but no effect.

How to implement it?

EDIT: Note that I am not looking for any animation XML file that shows/hides a fragment. What I want is HOW to play an animation on a DialogFragment that is already on the screen, and after animation playing done, the DialogFragment should still exist on screen.

wizardlee
  • 841
  • 7
  • 13
  • 1
    Use this to code the animation http://stackoverflow.com/questions/13402782/show-dialogfragment-with-animation-growing-from-a-point – koherent Feb 16 '15 at 08:11
  • 1
    And use this xml code https://gist.github.com/simon-heinen/9795036 for applying the shake animation – koherent Feb 16 '15 at 08:11

1 Answers1

2

A view which can be animated needs a parent view in it's attached window. However, Dialog itself has a window,so only its content part can be animated, You can implement onCreateView in DialogFragmentto give the dialog a custom layout content, then the custom part can be animated.

jobcrazy
  • 983
  • 7
  • 16