One: Show hidden animation
Create a Anim directory in the Res directory and create a alpha.xml file inside
<?xml version= "1.0" encoding= "Utf-8"? ><set xmlns:android= "Http://schemas.android.com/apk/res/android" android:shareinterpolator= "false" > <alpha android:fromalpha= "1.0" android:toalpha= "0" android:duration= ></alpha> </set>
Add a picture to the displayed page, and then in the Mainactivity.java file, get the object that needs to be animated, get an animated object that will animate the object to animate the method
Package Cn.szy.com;import Android.app.activity;import Android.os.bundle;import android.view.animation.Animation; Import Android.view.animation.animationutils;import Android.widget.imageview;public class MainActivity extends Activity { /** called when the activity is first created. * /@Override public void OnCreate (Bundle Savedinstan Cestate) { super.oncreate (savedinstancestate); Setcontentview (r.layout.main); Animation Animation = Animationutils.loadanimation (this, r.anim.alpha); Animation.setfillafter (true); ImageView ImageView = (ImageView) This.findviewbyid (r.id.imageview1); Imageview.startanimation (animation); }}
Two: Mobile animation
Create a Anim directory in the Res directory, then create a translate.xml file inside it and then load it in the animation.
<?xml version= "1.0" encoding= "Utf-8"? ><set xmlns:android= "Http://schemas.android.com/apk/res/android" android:shareinterpolator= "false" ><translate android:fromxdelta= "0" Android:fromydelta = "0" android:toxdelta= " android:toydelta=" " android:duration=" ></translate > </set>
Three: Rotate animation
Create a Anim directory in the Res directory, then create a rotate.xml file inside it and then load it in the animation.
<?xml version= "1.0" encoding= "Utf-8"? ><set xmlns:android= "Http://schemas.android.com/apk/res/android" android:shareinterpolator= "false" ><rotate android:fromdegrees= "0" android: Todegrees= "android:pivotx=" 50% " android:pivoty=" 50% "android:duration=" >< /rotate> </set>
Four: Enlarge animation
Create a Anim directory in the Res directory, then create a scale.xml file inside it and then load it in the animation.
<?xml version= "1.0" encoding= "Utf-8"? ><set xmlns:android= "Http://schemas.android.com/apk/res/android" android:shareinterpolator= "false" ><scale android:fromxscale= "1.0" android:fromyscale= "1.0" android:toxscale= "5.0" android:toyscale= "5.0" android:pivotx= "50%" android:pivoty= "50%" android:duration= "/></set>"
V: Set animation, the action of multiple animations written into a file, in order and time to call, you can achieve some complex animation
<?xml version= "1.0" encoding= "Utf-8"? ><set xmlns:android= "Http://schemas.android.com/apk/res/android" android:shareinterpolator= "false" ><translate android:fromxdelta= "0" Android:fromydelta = "0" android:toxdelta= " android:toydelta=" " android:duration=" ></translate > <scale android:fromxscale= "1.0" android:fromyscale= "1.0" android:toxscale= "5.0" android:toyscale= "5.0" android:pivotx= "50%" android:pivoty= "50%" android:duration= "5000" /> <alpha android:fromalpha= "1.0" android:toalpha= "0" android:duration= "5000" /></set>
The realization of Java-android's animation