Sayak
Sayak

Reputation: 347

How to create basic Image animations for tablets using "android.animation" package

I have created some applications for image and movies using android.view package. Now I want to create the same for the Android tablets.

I see that I can use android.animation packages for Android 3.0, but I cannot find any documentation to apply fade, zoom effects using this package. I am trying to convert all my source code in this package.

How do I use the ValueAnimator and ObjectAnimator? In the Api Demo, I found this code piece for fading. But how do I assign the Alpha value? In view.animation, I had fromAlpha, toAlpha...

ValueAnimator fadeAnim = ObjectAnimator.ofFloat(newBall, "alpha", 1f, 0f);
        fadeAnim.setDuration(250);
        fadeAnim.addListener(new AnimatorListenerAdapter() {
            @Override
            public void onAnimationEnd(Animator animation) {
                balls.remove(((ObjectAnimator)animation).getTarget());

            }
        });

Again I have this code piece:

ValueAnimator anim = ValueAnimator.ofFloat(0f, 1f);
anim.setDuration(500);
anim.start();

When do I use ValuAnimator and when do I use ObjectAnimator?

Upvotes: 2

Views: 1077

Answers (1)

Emil Sjölander
Emil Sjölander

Reputation: 1793

there are two blogposts on this subject on the android developer blog, http://android-developers.blogspot.com/2011/02/animation-in-honeycomb.html and http://android-developers.blogspot.com/2011/05/introducing-viewpropertyanimator.html

I strongly recomend both articles as I got a very good understanding of the new animation APIs after reading them.

Upvotes: 1

Related Questions