Thank you Mu---eclipse_xu network
Layout file: Activity_main.xml
1<framelayout xmlns:android= "Http://schemas.android.com/apk/res/android"2Xmlns:tools= "Http://schemas.android.com/tools"3Android:layout_width= "Match_parent"4android:layout_height= "Match_parent"5tools:context= "Com.example.animationapp.MainActivity" >6 7<ImageView8Android:id= "@+id/im0"9Android:layout_width= "Wrap_content"Tenandroid:layout_height= "Wrap_content" Oneandroid:paddingleft= "3DP" Aandroid:paddingtop= "3DP" -Android:src= "@drawable/b"/> - the<ImageView -Android:id= "@+id/im1" -Android:layout_width= "Wrap_content" -android:layout_height= "Wrap_content" +android:paddingleft= "3DP" -android:paddingtop= "3DP" +Android:src= "@drawable/C"/> A at<ImageView -Android:id= "@+id/im2" -Android:layout_width= "Wrap_content" -android:layout_height= "Wrap_content" -android:paddingleft= "3DP" -android:paddingtop= "3DP" inAndroid:src= "@drawable/d"/> - to<ImageView +Android:id= "@+id/im3" -Android:layout_width= "Wrap_content" theandroid:layout_height= "Wrap_content" *android:paddingleft= "3DP" $android:paddingtop= "3DP"Panax NotoginsengAndroid:src= "@drawable/E"/> - the<ImageView +Android:id= "@+id/im4" AAndroid:layout_width= "Wrap_content" theandroid:layout_height= "Wrap_content" +android:paddingleft= "3DP" -android:paddingtop= "3DP" $Android:src= "@drawable/F"/> $ -<ImageView -Android:id= "@+id/im5" theAndroid:layout_width= "Wrap_content" -android:layout_height= "Wrap_content"Wuyiandroid:paddingleft= "3DP" theandroid:paddingtop= "3DP" -android:src= "@drawable/g"/> Wu -<ImageView AboutAndroid:id= "@+id/im6" $Android:layout_width= "Wrap_content" -android:layout_height= "Wrap_content" -android:paddingleft= "3DP" -android:paddingtop= "3DP" AAndroid:src= "@drawable/h"/> + the<ImageView -Android:id= "@+id/im7" $Android:layout_width= "Wrap_content" theandroid:layout_height= "Wrap_content" theAndroid:src= "@drawable/A"/> the the</FrameLayout>
View Code
Picture Resources
Mainactivity.java
1 PackageCom.example.animationapp;2 3 Importjava.util.ArrayList;4 Importjava.util.List;5 6 Importandroid.support.v7.app.ActionBarActivity;7 ImportAndroid.animation.ObjectAnimator;8 ImportAndroid.os.Bundle;9 ImportAndroid.view.Menu;Ten ImportAndroid.view.MenuItem; One ImportAndroid.view.View; A ImportAndroid.view.View.OnClickListener; - ImportAndroid.view.animation.BounceInterpolator; - ImportAndroid.widget.ImageView; the ImportAndroid.widget.Toast; - - Public classMainactivityextendsActionbaractivityImplementsOnclicklistener { - + Private int[] res ={r.id.im0, r.id.im1,r.id.im2, - R.ID.IM3,R.ID.IM4,R.ID.IM5,R.ID.IM6,R.ID.IM7}; + A Privatelist<imageview> list =NewArraylist<imageview>(); at - Private BooleanFlag =true; - - @Override - protected voidonCreate (Bundle savedinstancestate) { - Super. OnCreate (savedinstancestate); in Setcontentview (r.layout.activity_main); - to Initview (); + } - the Private voidInitview () { * $ for(inti = 0; i < res.length; i++){Panax NotoginsengImageView im =(ImageView) Findviewbyid (Res[i]); -Im.setonclicklistener ( This); the list.add (IM); + } A } the + @Override - Public voidOnClick (View v) { $ Switch(V.getid ()) { $ //im7 final layout, superimposed on top - Caser.id.im7:{ - the if(flag) { - startanimation ();WuyiFlag =false; the}Else{ - closeanimation (); WuFlag =true; - } About Break; $ } - - default: -Toast.maketext (mainactivity. This, V.getid () + "OK", Toast.length_short). Show (); A Break; + } the } - $ Private voidcloseanimation () { the for(inti = 0;i<res.length-1; i++){ theObjectanimator OA =objectanimator.offloat (List.get (i), the"Translationy", i*200F, 0F); theOa.setduration (100); - //Oa.setstartdelay (50*i); in Oa.start (); the } the } About the Private voidstartanimation () { the //all you need to do is pop up the remaining 7 icons, the top icon im7 the for(inti = 0;i<res.length-1; i++){ + //Property Animation Action class -Objectanimator OA =objectanimator.offloat (List.get (i), the"Translationy", 0F, i*200F);BayiOa.setduration (200); the //Oa.setinterpolator (New Bounceinterpolator ()); the //Oa.setstartdelay (200*i); - Oa.start (); - } the } the the}
View Code
Objectanimator Properties Animation App Demo