background preloader

Animations

Facebook Twitter

Great animations with PageTransformer. Great animations with PageTransformer The Android ViewPager has become a fairly popular component among Android apps.

Great animations with PageTransformer

It’s simple, intuitive and it offers great functionality. You can often see it in action in setup wizards, image galleries, and it’s a great way to separate your app’s content. The standard ViewPager implementation works great, but the cool guys at Google have created something named PageTransformer. PageTransformer is an interface that allows you to modify the default page slide animation. So how does it work? We can now start animating the pages based on their position which can be obtained from the position parameter of the transformPage() method. “The position parameter indicates where a given page is located relative to the center of the screen. Now that we understand how the transformer works, we can start animating the pages’ properties relative to their position. The Android developer page provides a couple of cool transitions. But wait, there’s more! Check this out! Android - Fragment lost transition animation after configuration change. View Animation. You can use the view animation system to perform tweened animation on Views.

View Animation

Tween animation calculates the animation with information such as the start point, end point, size, rotation, and other common aspects of an animation. A tween animation can perform a series of simple transformations (position, size, rotation, and transparency) on the contents of a View object. So, if you have a TextView object, you can move, rotate, grow, or shrink the text. If it has a background image, the background image will be transformed along with the text. Property Animation. The property animation system is a robust framework that allows you to animate almost anything.

Property Animation

You can define an animation to change any object property over time, regardless of whether it draws to the screen or not. A property animation changes a property's (a field in an object) value over a specified length of time. To animate something, you specify the object property that you want to animate, such as an object's position on the screen, how long you want to animate it for, and what values you want to animate between. The property animation system lets you define the following characteristics of an animation: Duration: You can specify the duration of an animation. Introducing ViewPropertyAnimator. [This post is by Chet Haase, an Android engineer who specializes in graphics and animation, and who occasionally posts videos and articles on these topics on his CodeDependent blog at graphics-geek.blogspot.com. — Tim Bray] In an earlier article, Animation in Honeycomb, I talked about the new property animation system available as of Android 3.0.

Introducing ViewPropertyAnimator

This new animation system makes it easy to animate any kind of property on any object, including the new properties added to the View class in 3.0. In the 3.1 release, we added a small utility class that makes animating these properties even easier. First, if you’re not familiar with the new View properties such as alpha and translationX, it might help for you to review the section in that earlier article that discusses these properties entitled, rather cleverly, “View properties”. Go ahead and read that now; I’ll wait. Okay, ready? Refresher: Using ObjectAnimator ObjectAnimator.ofFloat(myView, "alpha", 0f).start(); Animation in Honeycomb. [This post is by Chet Haase, an Android engineer who specializes in graphics and animation, and who occasionally posts videos and articles on these topics on his CodeDependent blog at graphics-geek.blogspot.com. — Tim Bray] One of the new features ushered in with the Honeycomb release is a new animation system, a set of APIs in a whole new package (android.animation) that makes animating objects and properties much easier than it was before.

Animation in Honeycomb

"But wait! " you blurt out, nearly projecting a mouthful of coffee onto your keyboard while reading this article, "Isn't there already an animation system in Android? " Animation Prior to Honeycomb Indeed, Android already has animation capabilities: there are several classes and lots of great functionality in the android.view.animation package.

But there are a couple of major pieces of functionality lacking in the previous system. For one thing, you can animate Views... and that's it.