Android Ring Menu (Processed menu key and return key + added animation)

Source: Internet
Author: User

Don't say much nonsense, look first:



<relativelayout xmlns:android= "http://schemas.android.com/apk/res/android" xmlns:tools= "http// Schemas.android.com/tools "android:layout_width=" match_parent "android:layout_height=" match_parent "> <Rela        Tivelayout android:id= "@+id/level1" android:layout_width= "100DP" android:layout_height= "50DP" Android:layout_alignparentbottom= "true" android:layout_centerhorizontal= "true" android:background= "@drawable            /level1 "> <imageview android:id=" @+id/icon_home "android:layout_width=" Wrap_content " android:layout_height= "Wrap_content" android:layout_centerinparent= "true" Android:backgrou nd= "@drawable/icon_home"/> </RelativeLayout> <relativelayout android:id= "@+id/level2" and Roid:layout_width= "180DP" android:layout_height= "90DP" android:layout_alignparentbottom= "true" Androi D:layout_centerhorizontal= "true" Android:background= "@drawable/level2" > <imageview android:id= "@+id/icon_search" Android:lay Out_width= "Wrap_content" android:layout_height= "Wrap_content" android:layout_alignparentbottom= "true "Android:layout_alignparentleft=" true "android:layout_marginbottom=" 10DP "android:layout _marginleft= "10DP" android:background= "@drawable/icon_search"/> <imageview android:id=            "@+id/icon_menu" android:layout_width= "wrap_content" android:layout_height= "Wrap_content" Android:layout_centerhorizontal= "true" android:layout_margintop= "5DP" android:background= "@drawable /icon_menu "/> <imageview android:id=" @+id/icon_myyouku "android:layout_width=" Wrap_con Tent "android:layout_height=" Wrap_content "android:layout_alignparentbottom=" true "Androi D:layout_alignparentrighT= "true" android:layout_marginbottom= "10DP" android:layout_marginright= "10DP" Android:bac        kground= "@drawable/icon_myyouku"/> </RelativeLayout> <relativelayout android:id= "@+id/level3"        Android:layout_width= "280DP" android:layout_height= "140DP" android:layout_alignparentbottom= "true"            Android:layout_centerhorizontal= "true" android:background= "@drawable/level3" > <imageview Android:id= "@+id/channel1" android:layout_width= "wrap_content" android:layout_height= "wrap_content "Android:layout_alignparentbottom=" true "android:layout_alignparentleft=" true "android:l Ayout_marginbottom= "10DP" android:layout_marginleft= "10DP" android:background= "@drawable/channel1"/            > <imageview android:id= "@+id/channel2" android:layout_width= "Wrap_content" Android:layout_height= "WRap_content "android:layout_above=" @id/channel1 "android:layout_alignleft=" @id/channel1 " Android:layout_marginbottom= "10DP" android:layout_marginleft= "20DP" android:background= "@drawable/ch            Annel2 "/> <imageview android:id=" @+id/channel3 "android:layout_width=" Wrap_content " android:layout_height= "Wrap_content" android:layout_above= "@id/channel2" Android:layout_ali            gnleft= "@id/channel2" android:layout_marginbottom= "5DP" android:layout_marginleft= "30DP" android:background= "@drawable/channel3"/> <imageview android:id= "@+id/channel4" Androi D:layout_width= "Wrap_content" android:layout_height= "Wrap_content" android:layout_centerhorizontal= " True "android:layout_margintop=" 10DP "android:background=" @drawable/channel4 "/> <image View android:Id= "@+id/channel7" android:layout_width= "wrap_content" android:layout_height= "Wrap_content" Android:layout_alignparentbottom= "true" android:layout_alignparentright= "true" Android:layout_mar                Ginbottom= "10DP" android:layout_marginright= "10DP" android:background= "@drawable/channel7"/>            <imageview android:id= "@+id/channel6" android:layout_width= "Wrap_content" android:layout_height= "Wrap_content" android:layout_above= "@id/channel7" android:layout_alignright= " @id/channel7 "android:layout_marginbottom=" 10DP "android:layout_marginright=" 20DP "Androi d:background= "@drawable/channel6"/> <imageview android:id= "@+id/channel5" Android Oid:layout_width= "Wrap_content" android:layout_height= "wrap_content" android:layout_above= "@id/chann El6 "Android:layout_alignright= "@id/channel6" android:layout_marginbottom= "5DP" android:layout_marginright= "30DP" android:background= "@drawable/channel5"/> </RelativeLayout></RelativeLayout>

Package Com.example.circlemenuofbottom.anim;import Android.view.animation.rotateanimation;import android.widget.relativelayout;/** * @author LZD * * qq:2622596982 * * Email: [email protected] * * QQ Group: 27759 9214 */public class Myanimationutils {/** * out animation---clockwise out * * @param view * Animate object */public static void Animao UT (relativelayout view) {/* * rotateanimation animation = new Rotateanimation (0,, * view.getwidth ()/2, View.getheigh T ()); Animation.setduration (500); * Animation.setfillafter (TRUE); View.startanimation (animation); */animaout (view, 0);} /** * Go out of the animation---counterclockwise * * @param view * Animate object */public static void Animain (Relativelayout view) {/* *//clockwise in/ /Rotateanimation animation = new Rotateanimation (In//* 360,view.getwidth ()/2, View.getheight ()); Counterclockwise into rotateanimation * animation = new Rotateanimation ( -180, -360, View.getwidth ()/* 2,view.getheight ()); Animation.setduration (500); * Animation.setfillafter (TRUE); View.startanimation (ANimation); */animain (view, 0);} /** * out of animation---clockwise out * * @param view * Animate object * @param offsettime * Time delay execution */public static void Ani Maout (relativelayout view, int offsettime) {rotateanimation animation = new Rotateanimation (0, 180,view.getwidth ()/2, VI Ew.getheight ()); animation.setduration (+); Animation.setstartoffset (offsettime); Animation.setfillafter (true); View.startanimation (animation);} public static void Animain (relativelayout view, int offsettime) {//clockwise in//Rotateanimation animation = new Rotateanimation (180,//360,view.getwidth ()/2, View.getheight ());//Counter-clockwise rotateanimation animation = new Rotateanimation (-180,-360, View.getwidth ()/2, View.getheight ()); animation.setduration; Animation.setstartoffset (offsettime); Animation.setfillafter (True); view.startanimation (animation);}}


Key processing ideas:

/* * Listening Menu key, when the user click on the menu key, show and hide the first level and level two menu * * Monitor the return key, and then press exit program */private long exittime = 0; @Overridepublic boolean onKeyDown (int KeyCode, KeyEvent event) {//Menu key Processing if (event.getaction () = = Keyevent.action_down && keycode = keyevent.keycode_m ENU) {//If the first-level menu is displayed, hide all if (IsShowLevel1) {myanimationutils.animaout (levels); IsShowLevel1 = False;if (IsShowLevel2) { Myanimationutils.animaout (level2,120); IsShowLevel2 = False;if (isShowLevel3) {myanimationutils.animaout (level3,120 ); isShowLevel3 = false;}}} else{//if the first level menu-style hidden, show A, level two menu myanimationutils.animain; Myanimationutils.animain (level2); isShowLevel1 = True;isshowlevel2 = true;}} Return key if (event.getaction () = = Keyevent.action_down && keycode = = keyevent.keycode_back) {if ( System.currenttimemillis ()-exittime > () {toast.maketext (this, "Press the Return key again", Toast.length_short). Show (); Exittime = System.currenttimemillis ();} Else{finish (); System.exit (0);} return true;} Return Super.onkeydown (KeyCode, event);}



There is nothing to say, take a closer look on the full understanding, if there are questions, please contact me or to the group to communicate.


Last attached: http://download.csdn.net/detail/escdelete/8340545






Android Ring Menu (Processed menu key and return key + added animation)

Related Article

E-Commerce Solutions

Leverage the same tools powering the Alibaba Ecosystem

Learn more >

Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

Learn more >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.