Get House, menu icon ImageView object, get three rings relativelayout Object
Set the Click event to the menu icon (icon_menu)
Defines a member variable islevel3show to store whether the third-level menu is displayed
Judging the above variables to show the hidden third level menu, define a class to animate the effect
Toggle variable,islevel3show=!islevel3show
Define a tool class myutilsto achieve rotational animation
Define a startanimout ()
Gets the rotateanimation object, the default center of the rotated object is the upper-left corner, and the start degree defaults to a horizontal right of 0 degrees, clockwise; constructor: Start degree, end degree, center Point x (half width), center y (height)
Call the setduration () method of the rotateanimation Object , set the execution time, parameter: milliseconds
Call the Setfillafter () method of the rotateanimation Object , set the hold state after execution, parameter: Boolean
Define a startanimin (), parameter:relativelayout object, delay milliseconds
Like the above, the degrees are different, from the degree of longitude to the degree of
Call the Setstartoffset () method of the rotateanimation object to delay playback
Set the Click event to the House icon (icon_home)
Determine when the level two menu is displayed, hide it, and hide it when the level three menu is displayed
When it hides, let him show
Mainactivity.java
PackageCom.tsh.myyouku;Importandroid.app.Activity;ImportAndroid.os.Bundle;ImportAndroid.view.View;ImportAndroid.view.View.OnClickListener;ImportAndroid.widget.ImageView;Importandroid.widget.RelativeLayout; Public classMainactivityextendsActivityImplementsOnclicklistener {PrivateImageView Icon_home; PrivateImageView Icon_menu; Privaterelativelayout Level1; PrivateRelativelayout Level2; Privaterelativelayout level3; Private Booleanislevel3show=true; Private Booleanislevel2show=true; @Overrideprotected voidonCreate (Bundle savedinstancestate) {Super. OnCreate (savedinstancestate); Setcontentview (R.layout.activity_main); Icon_home=(ImageView) Findviewbyid (r.id.icon_home); Icon_menu=(ImageView) Findviewbyid (R.id.icon_menu); Level1=(relativelayout) Findviewbyid (R.ID.LEVEL1); Level2=(relativelayout) Findviewbyid (R.ID.LEVEL2); Level3=(relativelayout) Findviewbyid (R.ID.LEVEL3); Icon_menu.setonclicklistener ( This); Icon_home.setonclicklistener ( This); } //Handling Click events@Override Public voidOnClick (View v) {Switch(V.getid ()) { CaseR.id.icon_menu://Menu Icon if(islevel3show) {//HiddenMyutils.startanimout (level3,0); }Else{ //Showmyutils.startanimin (LEVEL3); } islevel3show=!islevel3show; Break; CaseR.id.icon_home://Menu Icon if(islevel2show) {//HiddenMyutils.startanimout (level2,0); if(islevel3show) {myutils.startanimout (LEVEL3,100); Islevel3show=false; } }Else{ //Showmyutils.startanimin (LEVEL2); } islevel2show=!islevel2show; Break; } }}
Myutils.java
PackageCom.tsh.myyouku;Importandroid.view.animation.RotateAnimation;Importandroid.widget.RelativeLayout; Public classMyutils {/*** Spin away *@paramView*/ Public Static voidStartanimout (Relativelayout view,LongTimes ) {rotateanimation rotateanimation=NewRotateanimation (0, View.getwidth ()/2, View.getheight ()); Rotateanimation.setduration (1000); Rotateanimation.setfillafter (true); Rotateanimation.setstartoffset (times); View.startanimation (rotateanimation); } /*** Rotate to enter *@paramLevel3*/ Public Static voidstartanimin (relativelayout view) {rotateanimation rotateanimation=NewRotateanimation (View.getwidth ()/2, View.getheight ()); Rotateanimation.setduration (1000); Rotateanimation.setfillafter (true); View.startanimation (rotateanimation); }}
[Android] Youku ring menu-Rotate animation