Introduced
The Android platform offers two animation systems: Property Animation (Android 3.0 introduction) and view Animation. Both of these animations are available, but property animation is preferred because it is more flexible and provides more powerful functionality. In addition to this, you can also use drawable Animation, which allows you to load a series of picture resources and play them in a frame in a specified order.
Property Animation
Introduced in Android 3.0 (API level One), the property animation system lets your animate properties of any object, Includi Ng ones that is not rendered to the screen. The system is extensible and lets your animate properties of custom types as well.
In Android 3.0 (API 11) was introduced, property animation lets you animate any object, including those objects that are not rendered to the screen. The property Animation is extensible and supports the object's custom attribute type animations.
View Animation
View Animation is the older system with can only being used for views. It is relatively easy to setup and offers enough capabilities to meet many application ' s needs.
View Animation is an old animation system and can only be used on a View object. It is relatively simple to use and provides enough animation to meet the needs of many applications.
drawable Animation
drawable animation involves displaying drawable resources One after another, like a roll of film. This method of animation was useful if you want to animate things that was easier to represent with drawable resources, suc h as a progression of bitmaps.
drawable animation One after another to show a series of picture resources, like a roll of film.
Android Property animation is available only on Android 3.0 (API 11), but fortunately already has the open source God to help us solve this problem. This project is nineoldandroids .
nineoldandroids Honeycomb animation API to the entire Android version platform, making valueanimator, objectanimator, etc. honeycomb Animation API can not change a line of code, only modify the import package name is fully compatible with the new API.
Usage
If you are familiar with the Honeycomb animation API, then it is very simple to use, just replace the import android.animation.ObjectAnimator with Com.nineoldandroids.animation.ObjectAnimator can be.
?
123456 |
valueanimator Coloranim = Obje Ctanimator.ofint ( this ,  "BackgroundColor" ,  /*red*/0xffff8080,/*blue*/ 0xff8080ff ); coloranim.setduration ( 3000 "; coloranim.setevaluator ( argbevaluator ()); Coloranim.setrepeatcount (valueanimator.infinite); coloranim.setrepeatmode (valueanimator.reverse); coloranim.start (); |
Nineoldandroids Library is almost completely compatible with the latest Android 3.0 property Animation API
?
123456789101112 |
AnimatorSet set =
new AnimatorSet();
set.playTogether(
ObjectAnimator.ofFloat(myView,
"rotationX"
,
0
,
360
),
ObjectAnimator.ofFloat(myView,
"rotationY"
,
0
,
180
),
ObjectAnimator.ofFloat(myView,
"rotation"
,
0
, -
90
),
ObjectAnimator.ofFloat(myView,
"translationX"
,
0
,
90
),
ObjectAnimator.ofFloat(myView,
"translationY"
,
0
,
90
),
ObjectAnimator.ofFloat(myView,
"scaleX"
,
1
,
1
.5f),
ObjectAnimator.ofFloat(myView,
"scaleY"
,
1
,
0
.5f),
ObjectAnimator.ofFloat(myView,
"alpha"
,
1
,
0
.25f,
1
)
);
set.setDuration(
5 *
1000
).start();
|
Android Open Source Animation frame: Nineoldandroids