Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Custom Flip animation between fragments android support package

Tags:

android

I am trying to find out how to create flip animation between 2 fragments.

I have tried the CardFlip training as a guide, but don't seem to be able to achieve it. I am using the android support package and set it to tween animation, but not successful.

How to implement flipping animations between fragment?

here is the first 2 xml i created from the guide, maybe you could see if am doing something wrong. screen_flip_left_in.xml:

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android" >

     <!-- Before rotating, immediately set the alpha to 0. -->
    <alpha
        android:valueFrom="1.0"
        android:valueTo="0.0"
        android:propertyName="alpha"
        android:duration="0" />

    <!-- Rotate. -->
    <rotate
        android:valueFrom="-180"
        android:valueTo="0"
        android:propertyName="rotationY"
        android:interpolator="@android:anim/accelerate_decelerate_interpolator"
        android:duration="@integer/card_flip_time_full"/>

    <!-- Half-way through the rotation (see startOffset), set the alpha to 1. -->
    <alpha
        android:valueFrom="0.0"
        android:valueTo="1.0"
        android:propertyName="alpha"
        android:startOffset="@integer/card_flip_time_half"
        android:duration="1" />
</set>

screen_flip_left_out.xml:

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android" >
        <!-- Rotate. -->
    <rotate
        android:valueFrom="0"
        android:valueTo="180"
        android:propertyName="rotationY"
        android:interpolator="@android:anim/accelerate_decelerate_interpolator"
        android:duration="@integer/card_flip_time_full" />

    <!-- Half-way through the rotation (see startOffset), set the alpha to 0. -->
    <alpha
        android:valueFrom="1.0"
        android:valueTo="0.0"
        android:propertyName="alpha"
        android:startOffset="@integer/card_flip_time_half"
        android:duration="1" />

</set>
like image 358
irobotxx Avatar asked Feb 20 '13 12:02

irobotxx


People also ask

How do you animate fragment transitions?

At a high level, here's how to make a fragment transition with shared elements: Assign a unique transition name to each shared element view. Add shared element views and transition names to the FragmentTransaction . Set a shared element transition animation.

What is popEnterAnim?

The enterAnim and exitAnim is applied when navigating to or from the destination the "regular way", while popEnterAnim is applied to the destination when it is shown as a result of the destination "above" it being popped from the backstack.

What is transition in Android?

Android's transition framework allows you to animate all kinds of motion in your UI by simply providing the starting layout and the ending layout.


1 Answers

android:propertyName is only for ObjectAnimator (Honeycomb+) animations, not view animations from Gingerbread. A card flip animation is only possible using Honeycomb animator api's. I created a fork of the support library to allow using Animator apis from NineOldAndroids for fragment transitions. Use the animator-transition branch of my github project. Once you have the modified support library look at http://developer.android.com/training/animation/cardflip.html to make the animator xml.

like image 88
mark.kedzierski Avatar answered Dec 11 '22 08:12

mark.kedzierski