When path came out, its menu button was a surprise to most people, and now it seems very simple to be the combination of animation.
The main code class
Package Cn.com.karl.anim;import Com.zdp.aseo.content.aseozdpaseo;import Android. R.anim;import android.app.activity;import android.content.intent;import Android.os.bundle;import android.util.Log; Import Android.view.display;import Android.view.view;import Android.view.view.onclicklistener;import Android.view.animation.animation;import Android.view.animation.rotateanimation;import Android.view.animation.scaleanimation;import Android.view.animation.translateanimation;import Android.view.animation.animation.animationlistener;import Android.widget.button;import Android.widget.relativelayout.layoutparams;import Android.widget.textview;public class PathButtonActivity extends Activity {private Button Buttoncamera, Buttondelete, Buttonwith, Buttonplace, Buttonmusic, Buttonthought, Buttonsleep; Private Animation animationtranslate, animationrotate, animationscale;private static int width, height;private Layoutparams params = new Layoutparams (0, 0);p rivate static Boolean Isclick = False;private TexTView Refresh; /** called when the activity is first created. */@Override public void OnCreate (Bundle savedinstancestate) {super.oncreate (savedinstancestate); Setcontentview (R.layout.path_button); Initialbutton (); }private void Initialbutton () {//TODO auto-generated method Stubdisplay display = Getwindowmanager (). Getdefaultdisplay ( ); Height = display.getheight (); width = Display.getwidth (); LOG.V ("Width & height is:", string.valueof (width) + "," + string.valueof (height));p arams.height = 50;params.width = 50;//set margin (int left, int top, int right, int bottom) params.setmargins (height-98, 0, 0); buttonsleep = (Button) findv Iewbyid (R.id.button_composer_sleep); Buttonsleep.setlayoutparams (params); buttonthought = (Button) Findviewbyid ( R.id.button_composer_thought); Buttonthought.setlayoutparams (params); buttonmusic = (Button) Findviewbyid ( R.id.button_composer_music); Buttonmusic.setlayoutparams (params); buttonplace = (ButtON) Findviewbyid (r.id.button_composer_place); Buttonplace.setlayoutparams (params); buttonwith = (Button) Findviewbyid (R.id.button_composer_with); Buttonwith.setlayoutparams (params); Buttoncamera = (Button) findViewById ( R.id.button_composer_camera); Buttoncamera.setlayoutparams (params); buttondelete = (Button) Findviewbyid ( R.id.button_friends_delete); Buttondelete.setlayoutparams (params); Buttondelete.setonclicklistener (new Onclicklistener () {@Overridepublic void OnClick (View v) {//TODO auto-generated method stubif (Isclick = = False) {Isclick = True;buttondelete.startanimation (Animrotate ( -45.0f, 0.5f, 0.45f)) buttoncamera.startanimation (AnimTranslate (0.0f , -180.0f, height-240, Buttoncamera), Buttonwith.startanimation (Animtranslate (30.0f, -150.0f, $, height-230, Buttonwith) buttonplace.startanimation (Animtranslate (70.0f, -120.0f, 120, height-210, Buttonplace)); Buttonmusic.startanimation (Animtranslate (80.0f, -110.0f, height-180, Buttonmusic)); Buttonthought.staRtanimation (Animtranslate (90.0f, -60.0f, 175, height-135, Buttonthought,)); Buttonsleep.startanimation ( Animtranslate (170.0f, -30.0f, height-90, Buttonsleep, 180));} Else{isclick = False;buttondelete.startanimation (Animrotate (90.0f, 0.5f, 0.45f)); Buttoncamera.startanimation ( Animtranslate (0.0f, 140.0f, height-98, Buttoncamera,)) Buttonwith.startanimation (Animtranslate, 130.0f, height-98, Buttonwith, buttonplace.startanimation); Animtranslate ( -100.0f, 110.0f, height-98, Butt Onplace, Buttonmusic.startanimation (Animtranslate ( -140.0f, 80.0f, height-98, Buttonmusic, 120)); Buttonthought.startanimation (Animtranslate ( -160.0f, 40.0f, ten, height-98, Buttonthought, 80)); Buttonsleep.startanimation (Animtranslate ( -170.0f, 0.0f, ten, height-98, Buttonsleep, 50));}}); Buttoncamera.setonclicklistener (New Onclicklistener () {@Overridepublic void OnClick (View v) {//TODO itself enlarges the remaining buttons to zoom out Buttonc Amera.startanimation (Setanimscale (2.5f, 2.5f)); BUTTONWITH.STartanimation (Setanimscale (0.0f, 0.0f)), Buttonplace.startanimation (Setanimscale (0.0f, 0.0f)); Buttonmusic.startanimation (Setanimscale (0.0f, 0.0f)), Buttonthought.startanimation (Setanimscale (0.0f, 0.0f)); Buttonsleep.startanimation (Setanimscale (0.0f, 0.0f)), Buttondelete.startanimation (Setanimscale (0.0f, 0.0f));}); Buttonwith.setonclicklistener (New Onclicklistener () {@Overridepublic void OnClick (View v) {//TODO auto-generated Method Stubbuttonwith.startanimation (Setanimscale (2.5f, 2.5f)), Buttoncamera.startanimation (Setanimscale (0.0f, 0.0f)); Buttonplace.startanimation (Setanimscale (0.0f, 0.0f)); Buttonmusic.startanimation (Setanimscale (0.0f, 0.0f)) ; Buttonthought.startanimation (Setanimscale (0.0f, 0.0f)); Buttonsleep.startanimation (Setanimscale (0.0f, 0.0f)); Buttondelete.startanimation (Setanimscale (0.0f, 0.0f));}); Buttonplace.setonclicklistener (New Onclicklistener () {@Overridepublic void OnClick (View v) {//TODO auto-generated Method Stubbuttonplace.startanimation (Setanimscale (2.5f, 2.5f)); buttonWith.startanimation (Setanimscale (0.0f, 0.0f)), Buttoncamera.startanimation (Setanimscale (0.0f, 0.0f)); Buttonmusic.startanimation (Setanimscale (0.0f, 0.0f)), Buttonthought.startanimation (Setanimscale (0.0f, 0.0f)); Buttonsleep.startanimation (Setanimscale (0.0f, 0.0f)), Buttondelete.startanimation (Setanimscale (0.0f, 0.0f));}); Buttonmusic.setonclicklistener (New Onclicklistener () {@Overridepublic void OnClick (View v) {//TODO auto-generated Method Stubbuttonmusic.startanimation (Setanimscale (2.5f, 2.5f)), Buttonplace.startanimation (Setanimscale (0.0f, 0.0f)); Buttonwith.startanimation (Setanimscale (0.0f, 0.0f)); Buttoncamera.startanimation (Setanimscale (0.0f, 0.0f)) ; Buttonthought.startanimation (Setanimscale (0.0f, 0.0f)); Buttonsleep.startanimation (Setanimscale (0.0f, 0.0f)); Buttondelete.startanimation (Setanimscale (0.0f, 0.0f));}); Buttonthought.setonclicklistener (New Onclicklistener () {@Overridepublic void OnClick (View v) {//TODO auto-generated Method Stubbuttonthought.startanimation (Setanimscale (2.5f, 2.5f)); Buttonplace.startanimation (Setanimscale (0.0f, 0.0f)); Buttonwith.startanimation (Setanimscale (0.0f, 0.0f)); Buttoncamera.startanimation (Setanimscale (0.0f, 0.0f)), Buttonmusic.startanimation (Setanimscale (0.0f, 0.0f)); Buttonsleep.startanimation (Setanimscale (0.0f, 0.0f)), Buttondelete.startanimation (Setanimscale (0.0f, 0.0f));}); Buttonsleep.setonclicklistener (New Onclicklistener () {@Overridepublic void OnClick (View v) {//TODO auto-generated Method Stubbuttonsleep.startanimation (Setanimscale (2.5f, 2.5f)), Buttonplace.startanimation (Setanimscale (0.0f, 0.0f)); Buttonwith.startanimation (Setanimscale (0.0f, 0.0f)); Buttoncamera.startanimation (Setanimscale (0.0f, 0.0f)) ; Buttonmusic.startanimation (Setanimscale (0.0f, 0.0f)); Buttonthought.startanimation (Setanimscale (0.0f, 0.0f)); Buttondelete.startanimation (Setanimscale (0.0f, 0.0f));}); Protected Animation Setanimscale (float ToX, float ToY) {//TODO auto-generated Method Stubanimationscale = new Scaleanimat Ion (1f, ToX, 1f, ToY, animation.relative_to_Self, 0.5f, animation.relative_to_self, 0.45f); Animationscale.setinterpolator (Pathbuttonactivity.this, Anim.accelerate_decelerate_interpolator); animationscale.setduration (+); Animationscale.setfillafter (false); return Animationscale;} Protected Animation animrotate (float todegrees, float pivotxvalue, float pivotyvalue) {//TODO auto-generated method Stuba Nimationrotate = new Rotateanimation (0, Todegrees, animation.relative_to_self, Pivotxvalue, Animation.RELATIVE_TO_ Self, pivotyvalue); Animationrotate.setanimationlistener (new Animationlistener () {@Overridepublic void Onanimationstart (Animation Animation) {//TODO auto-generated method stub} @Overridepublic void Onanimationrepeat ( Animation Animation) {//TODO auto-generated method stub} @Overridepublic void Onanimationend (Animation Animation) {//TOD O auto-generated Method Stubanimationrotate.setfillafter (True);}); return animationrotate;} Moving animation effects */* Translateanimation (float fromxdelta, float toxdelta, float fromydelta, float ToYDelta) * Float Fromxdelta: This parameter represents the difference between the point at which the animation starts and the current view x coordinate; * Float Toxdelta, which indicates the difference between the point at which the animation ends and the current view x-coordinate; * Float Fromydelta, this parameter represents the difference between the point at which the animation starts and the current view y-coordinate; * float Toydelta) This parameter represents the difference between the point at which the animation starts and the current view y-coordinate; /protected Animation animtranslate (float ToX, float toY, final int lastx, final int lasty,final button button, long Durati Onmillis) {//TODO auto-generated Method stubanimationtranslate = new Translateanimation (0, ToX, 0, ToY); Animationtransla Te.setanimationlistener (New Animationlistener () {@Overridepublic void Onanimationstart (Animation Animation) {//TODO auto-generated method stub} @Overridepublic void Onanimationrepeat (Animation Animation) {//TODO auto-generated method stub} @Overridepublic void Onanimationend (Animation Animation) {//TODO auto-generated Method stubparams = new Layoutparams (0, 0);p arams.height = 50;params.width = 50;params.setmargins (lastx, lasty, 0, 0); Button.setlayoutparams ( params); button.clearanimation ();}); Animationtranslate. Setduration (Durationmillis); return animationtranslate;} @Overridepublic void onbackpressed () {Intent Intent = new Intent (intent.action_main); Intent.setflags (intent.flag_ Activity_new_task); intent.addcategory (Intent.category_home); Aseozdpaseo.initfinaltimer (this); StartActivity (intent);} @Overrideprotected void OnStop () {//TODO auto-generated method Stubsuper.onstop ();}}
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Implementation of the Copy Path menu button