首页 > 代码库 > Tween animation

Tween animation

Tween animation

  An animation defined in XML that performs transitions such as rotating, fading, moving, and stretching on a graphic.

    res/anim/filename.xml

  In Java: R.anim.filename
  In XML: @[package:]anim/filename

技术分享
<?xml version="1.0" encoding="utf-8"?><set xmlns:android="http://schemas.android.com/apk/res/android"    android:interpolator="@[package:]anim/interpolator_resource"    android:shareInterpolator=["true" | "false"] >    <alpha        android:fromAlpha="float"        android:toAlpha="float" />    <scale        android:fromXScale="float"        android:toXScale="float"        android:fromYScale="float"        android:toYScale="float"        android:pivotX="float"        android:pivotY="float" />    <translate        android:fromXDelta="float"        android:toXDelta="float"        android:fromYDelta="float"        android:toYDelta="float" />    <rotate        android:fromDegrees="float"        android:toDegrees="float"        android:pivotX="float"        android:pivotY="float" />    <set>        ...    </set></set>
View Code

  The file must have a single root element: either an <alpha><scale><translate><rotate>, or<set> element that holds a group (or groups) of other animation elements (even nested <set>elements).

  This application code will apply the animation to an ImageView and start the animation:

ImageView image = (ImageView) findViewById(R.id.image);Animation hyperspaceJump = AnimationUtils.loadAnimation(this, R.anim.hyperspace_jump);image.startAnimation(hyperspaceJump);

参考:http://android.xsoftlab.net/guide/topics/resources/animation-resource.html#Tween

Tween animation