See a lot of open-source libraries have used this animation framework, I tried it, it is very powerful. Paste the test code to make it easy to use later
Package Com.test.animation;import Android.animation.valueanimator;import Android.app.activity;import Android.os.bundle;import Android.view.gravity;import Android.view.view;import Android.widget.Button;import Android.widget.linearlayout;import Com.nineoldandroids.animation.animator;import Com.nineoldandroids.animation.animatorset;import Com.nineoldandroids.animation.objectanimator;import Com.nineoldandroids.animation.propertyvaluesholder;import Com.nineoldandroids.view.viewhelper;import Com.nineoldandroids.view.viewpropertyanimator;public class Animationactivity extends Activity {button button; private void Initview () {linearlayout layout = new LinearLayout (this); Layout.setorientation (linearlayout.vertical); Layout.setgravity (gravity.center_horizontal); button = New button (this); Button.settext ("target"); Linearlayout.layoutparams params = new Linearlayout.layoutparams (LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAp_content); Layout.addview (button, params); Setcontentview (layout); } @Override protected void OnCreate (Bundle savedinstancestate) {super.oncreate (savedinstancestate); Initview ();//testAnim00 ();//TESTANIM0 ();//TESTANIM1 ();//testAnim2 (); TESTANIM3 ();//TESTANIM4 ();//TESTANIM5 ();//TESTANIM6 ();//TESTANIM7 ();//Startactivit Y (New Intent (This,animationcontextmenuactivity.class)); private void TestAnim00 () {Animator Animator1 = animatorutils.rotationclosetoright (Button). Setduration (2000); Animator Animator2 = animatorutils.rotationopenfromright (Button). Setduration (2000); Animator Animator3 = animatorutils.rotationclosevertical (Button). Setduration (2000); Animator Animator4 = animatorutils.rotationopenvertical (Button). Setduration (2000); Animator Animator5 = animatorutils.alphadisappear (Button). Setduration (2000); Animator Animator6 = Animatorutils.alphaappear (Button). Setduration (2000); Animator animator7 = animatorutils.translationright (button, +). Setduration (2000); Animator animator8 = animatorutils.translationleft (button, +). Setduration (2000); Final Animatorset set = new Animatorset ();//Set.play (Animator1). Before (Animator2)/*.after (Animator3). After (Animato R4). After (Animator5). After (ANIMATOR6). After (ANIMATOR7). After (ANIMATOR8) */;//set.play (Animator2). Before ( ANIMATOR3);//Set.play (Animator3) before (ANIMATOR4);//Set.play (ANIMATOR4). before (Animator5);//SET.P Lay (Animator5) before (ANIMATOR6);//Set.play (ANIMATOR6). before (animator7);//Set.play (ANIMATOR7). Before (Anim ATOR8); /*===============//after before can only have two, note the order of Before/after or use the following ===========================*/set.playsequentially (a NIMATOR1,ANIMATOR2,ANIMATOR3,ANIMATOR4,ANIMATOR5,ANIMATOR6,ANIMATOR7,ANIMATOR8); Set.start (); Button.setonclicklistener (new View).Onclicklistener () {@Override public void OnClick (View v) {set.start (); } }); private void TestAnim0 () {Animator anim1 = objectanimator.offloat (Button, "RotationX", 0). setduration (200 0); Animator anim2 = objectanimator.offloat (Button, "RotationX", 0, N). Setduration (2000); Final Animatorset set = new Animatorset (); Set.play (ANIM1). After (ANIM2); Set.start (); Button.setonclicklistener (New View.onclicklistener () {@Override public void OnClick (View v) { Set.start (); } }); } private void TestAnim1 () {objectanimator.offloat (button, "translationy", +). Setduration (+). Start (); private void TestAnim2 () {Animator Animator = objectanimator.offloat (Button, "Translationx", +). setduration (1000); Animator.addlistener (New Animator.animatorlistener () {@Override public voidOnanimationstart (Animator Animator) {} @Override public void Onanimationend (Animator ani Mator) {objectanimator.offloat (button, "Translationx", 0). Setduration (+). Start (); } @Override public void Onanimationcancel (Animator Animator) {} @Override public void Onanimationrepeat (Animator Animator) {}}); Animator.start (); private void TestAnim3 () {viewpropertyanimator.animate (button). Translationy (). Start (); Final Valueanimator animator = valueanimator.offloat (0, N). Setduration (2000); Animator.addupdatelistener (New Valueanimator.animatorupdatelistener () {@Override public void Onanim Ationupdate (Valueanimator animation) {//Viewhelper.setpivotx (button,0);//Viewhelper.setrot Ationx (Button, (Float) Animation.getanimatedvalue ()); Viewhelper.setpivoty (BUTton, 0); Viewhelper.setrotationy (Button, (Float) Animation.getanimatedvalue ()); Supporting use}); Animator.start (); Button.setonclicklistener (New View.onclicklistener () {@Override public void OnClick (View v) { Animator.start (); } }); } private void TestAnim4 () {//Left move 100, right move 100,alpha to 0.2 with 5 effect animatorset set = new Animatorset (); Set.playtogether (Button, "Translationx", Objectanimator.offloat), Objectanimator.offloat (Button, " Translationy ","), Objectanimator.offloat (button, "Alpha", 1, 0.2f)); Set.setduration (+). Start (); } private void TestAnim5 () {//Left move 100, right move 100,alpha to 0.2 objectanimator.ofpropertyvaluesholder (button, Pr Opertyvaluesholder.offloat ("Translationx", -100), Propertyvaluesholder.offloat ("Translationy", 100), Propertyvaluesholder.offloat ("Alpha", 1, 0.3f). Setduration (+). Start (); private void TestAnim6 () {//Viewpropertyanimator.animate (button). Translationx (+). Translationy (+). Setdurat Ion (+). Start ();//Viewpropertyanimator.animate (button). Rotationyby (720). Setduration (2000). Start (); Viewpropertyanimator.animate (Button). rotationyby (x). Y (+) setduration (+). Start ();//rotation angle is a multiple of 360, X ( ..) Y (..) Back for post-animation position}//===========================================================================demo==================== ===================================== private void TestAnim7 () {final LinearLayout layout = new LinearLayout (th IS); Layout.setorientation (linearlayout.vertical); Layout.setgravity (gravity.center_horizontal); Linearlayout.layoutparams params = new Linearlayout.layoutparams (LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT); for (int i = 0; i < 5; i++) {button btn = new button (this); Btn.settext ("btn" + i); Btn.settag (i); Layout.addview (btn, params); } button startbtn = New button (this); Startbtn.settext ("Start"); Startbtn.setonclicklistener (New View.onclicklistener () {@Override public void OnClick (View v) { if (!isadimateopen) {Isadimateopen = true; Doanimateopen (Layout.getchildat (0), 0, 5, 300); Doanimateopen (Layout.getchildat (1), 1, 5, 300); Doanimateopen (Layout.getchildat (2), 2, 5, 300); Doanimateopen (Layout.getchildat (3), 3, 5, 300); Doanimateopen (Layout.getchildat (4), 4, 5, 300); } else {isadimateopen = false; Doanimateclose (Layout.getchildat (0), 0, 5, 300); Doanimateclose (Layout.getchildat (1), 1, 5, 300); Doanimateclose (Layout.getchildat (2), 2, 5, 300); Doanimateclose (Layout.getchildat (3), 3, 5, 300); Doanimateclose (Layout.getchildat (4), 4, 5, 300); } } }); Layout.addview (startbtn, params); Setcontentview (layout); } Boolean isadimateopen = false; /** * Open Menu Animation * * @param view perform animated view * @param the Order of Index view in the animation sequence * @param number of total animation sequences * @param radius Animation radius */private void Doanimateopen (view view, int index, int total, int radius) {if (view.get Visibility ()! = view.visible) {view.setvisibility (view.visible); } Double degree = Math.PI * Index/((TOTAL-1) * 2); int translationx = (int) (RADIUS * Math.Cos (degree)); int translationy = (int) (RADIUS * Math.sin (degree)); Animatorset set = new Animatorset (); Contains the pan, zoom, and transparency animations Set.playtogether (objectanimator.offloat (View, "Translationx", 0, Translationx), Objectanimator.offLoat (View, "Translationy", 0, Translationy), objectanimator.offloat (view, "ScaleX", 1f, 1.5f), Objectanimator.offloat (View, "ScaleY", 1f, 1.5f), objectanimator.offloat (view, "Alpha", 1f, 1.5f)); The animation period is 500ms set.setduration (.). Start (); }/** * Close Menu Animation * * @param view perform animation view * @param the order of the index view in the animation sequence * @param the number of total animation sequences * @param radius Animation radius */private void Doanimateclose (final view view, int index, int total, int radius) {if (view.getvisibility () = view.visible) {view.setvisibility (view.visible); } Double degree = Math.PI * Index/((TOTAL-1) * 2); int translationx = (int) (RADIUS * Math.Cos (degree)); int translationy = (int) (RADIUS * Math.sin (degree)); Animatorset set = new Animatorset (); Contains the pan, zoom, and transparency animation Set.playtogether (objectanimator.offloat (view, "TranslaTionx ", Translationx, 0), objectanimator.offloat (view," Translationy ", Translationy, 0), OBJ Ectanimator.offloat (View, "ScaleX", 1.5f, 1f), objectanimator.offloat (view, "ScaleY", 1.5f, 1f), Objectanimator.offloat (View, "ScaleY", 1.5f, 1f)); Set.setduration (+). Start (); }}
Nineoldandroid Open Source Library easy to use demo