Is possible to use an Android Animator to animate a DialogFragment entry?
Asked Answered
D

0

9

I have a DialogFragment which I show() when the user clicks a button on my App.

I would like to set an animation to make a Z-axix rotation on the DialogFragment when it launches (i.e. a 3d card flip animation).

I have succesfully used the windowAnimationStyle and the following style to do simple animations (using the View Animation framework) when the DialogFragment is shown:

<style name="windowAnimationCardFlip" parent="@android:style/Animation.Dialog">
        <item name="android:windowEnterAnimation">@anim/card_flip_left_in</item>
        <item name="android:windowExitAnimation">@anim/card_flip_left_out</item>
 </style>

The problem is that the View Animation framework is (to the best of my knowledge), quite limited, and the only rotation that I'm able to do (on xml, at least) is a 2D XY rotation (I want a "3D" z axis rotation).

I tried to use the Property Animation framework (specifically an Object Animator, written in XML), but, while I'm able to achieve the effect when loading simple Fragments as described in the official android tutorials, when I try to apply that XML ObjectAnimator to the windowEnterAnimation attribute, nothing happens.

I would like to know, then, what could be happening? Is it possible to use an ObjectAnimator to animate the windowEntry event? If not, are there other solutions?

Doti answered 18/1, 2013 at 15:42 Comment(4)
Have you tried making a custom animation? (class extending from animation and overriding the applytransformation, with this approach you can use de z axis to do transformations)Sincerity
No, I haven't. Could you please give me some pointers?Doti
I will give you some example code of an CustomAnimation extending from Animation. The effect there is a rotation over the Z-axisSincerity
also check out these video's of Chet Haase, He works on the graphics animation engine of the Android framework. These video's were released just yesterday: graphics-geek.blogspot.be/2013/01/…Sincerity

© 2022 - 2024 — McMap. All rights reserved.