:
Production ideas:
1, the first analysis of this effect, in fact, can be understood as the three-level menu divided into Level1,level2,level3,level1 is always displayed. After clicking Level1, Level2 will appear, LEVEL3 will appear after clicking Level2, and clicking Level2,level3 and Level1,level2 will disappear after LEVEL3 appears. Then disappears and appears we used an animated effect.
2, the animation effect is rotateanimation, because we are all using the same effect, then we just write a class, the effect can be achieved. If we use rotateanimation, we will continue to reuse some code, so that the development efficiency will be relatively low.
3. The rotation of the rotateanimation into and out is a pit-because he rotates in the clockwise direction of the x-axis. You can look at the picture:
The whole idea is this, and then there are some operations:
Code:
1, Myanimation class:
public class Myanimation{public static void Animationin (view view) {Animationin (view,0);} public static void Animationout (view view) {animationout (view,0);} public static void Animationin (View view,long delay) {rotateanimation animation = new Rotateanimation (,, View.getwi DTH ()/2, View.getheight ()); animation.setduration; Animation.setfillafter (true); Animation.setstartoffset ( delay); view.startanimation (animation);} public static void Animationout (View view,long delay) {rotateanimation animation = new Rotateanimation (0, View.getwid Th ()/2, View.getheight ()); animation.setduration (+); Animation.setfillafter (true); Animation.setstartoffset ( delay); view.startanimation (animation);}}
2, Mainactivity class:
public class Mainactivity extends Activity implements Onclicklistener{private Boolean islevel2showed,islevel3showed; Private Relativelayout level1,level2,level3;private ImageButton home,menu; @Overrideprotected void OnCreate (Bundle Savedinstancestate) {super.oncreate (savedinstancestate); Setcontentview (r.layout.main); isLevel2showed = false; islevel3showed = False;initlayout (); Initimagebutton ();} public void Initlayout () {level1 = (relativelayout) Findviewbyid (r.id.relate_level1); Level2 = (relativelayout) Findviewbyid (R.ID.RELATE_LEVEL2); level3 = (relativelayout) Findviewbyid (R.ID.RELATE_LEVEL3); Level2.setvisibility ( view.invisible); level3.setvisibility (view.invisible);} public void Initimagebutton () {home = (ImageButton) Level1.findviewbyid (r.id.home); menu = (ImageButton) Level2.findviewbyid (R.id.menu); Home.setonclicklistener (this); Menu.setonclicklistener (this);} @Overridepublic void OnClick (View v) {switch (V.getid ()) {case R.id.home:if (!islevel2showed) {islevel2showed = true; Myanimation.animationin (LEVEL2);} else if (!islevel3showed) {islevel2showed = false; Myanimation.animationout (LEVEL2);} else{islevel2showed = false;islevel3showed = false; Myanimation.animationout (LEVEL3); Myanimation.animationout (level2,500);} Break;case R.id.menu:if (!islevel3showed) {islevel3showed = true; Myanimation.animationin (LEVEL3);} else{islevel3showed = false; Myanimation.animationout (LEVEL3);} Break;}}}
Source Download
Android custom controls: Old Youku three level menu (+ Demo)