android 高仿【优酷】圆盘旋转菜单…

早上无意看到了 优酷 这个应用,被这个应用的圆形转动盘菜单所吸引 
于是闲来无事解压了 该客户端的APK,轻轻的取出需要的几张图片,对此我身怀愧疚,娃哈哈 
搞了一下,主要是布局那块比较蛋疼点。 
效果图: 
android <wbr>高仿【优酷】圆盘旋转菜单 <wbr>的实现  
android <wbr>高仿【优酷】圆盘旋转菜单 <wbr>的实现  
android <wbr>高仿【优酷】圆盘旋转菜单 <wbr>的实现  

MyAnimation.java 
Java代码    收藏代码
  1. package com.ljp.youku;  
  2.   
  3. import android.view.ViewGroup;  
  4. import android.view.animation.Animation;  
  5. import android.view.animation.RotateAnimation;  
  6.   
  7. public class MyAnimation  
  8.     // 图标的动画(入动画)  
  9.     public static void startAnimationsIn(ViewGroup viewgroup, int durationMillis)  
  10.   
  11.         viewgroup.setVisibility(0);  
  12.         for (int 0viewgroup.getChildCount(); i++)  
  13.             viewgroup.getChildAt(i).setVisibility(0);  
  14.             viewgroup.getChildAt(i).setClickable(true);  
  15.             viewgroup.getChildAt(i).setFocusable(true);  
  16.          
  17.         Animation animation;  
  18.         animation new RotateAnimation(-1800Animation.RELATIVE_TO_SELF,  
  19.                 0.5f, Animation.RELATIVE_TO_SELF, 1.0f);  
  20.         animation.setFillAfter(true);  
  21.         animation.setDuration(durationMillis);  
  22.         viewgroup.startAnimation(animation);  
  23.   
  24.      
  25.   
  26.     // 图标的动画(出动画)  
  27.     public static void startAnimationsOut(final ViewGroup viewgroup,  
  28.             int durationMillis, int startOffset)  
  29.   
  30.         Animation animation;  
  31.         animation new RotateAnimation(0-180Animation.RELATIVE_TO_SELF,  
  32.                 0.5f, Animation.RELATIVE_TO_SELF, 1.0f);  
  33.         animation.setFillAfter(true);  
  34.         animation.setDuration(durationMillis);  
  35.         animation.setStartOffset(startOffset);  
  36.         animation.setAnimationListener(new Animation.AnimationListener()  
  37.             @Override  
  38.             public void onAnimationStart(Animation arg0) {}  
  39.             @Override  
  40.             public void onAnimationRepeat(Animation arg0) {}  
  41.             @Override  
  42.             public void onAnimationEnd(Animation arg0)  
  43.                 viewgroup.setVisibility(8);  
  44.                 for (int 0viewgroup.getChildCount(); i++)  
  45.                     viewgroup.getChildAt(i).setVisibility(8);  
  46.                     viewgroup.getChildAt(i).setClickable(false);  
  47.                     viewgroup.getChildAt(i).setFocusable(false);  
  48.                  
  49.              
  50.         });  
  51.         viewgroup.startAnimation(animation);  
  52.      
  53.   
  54.  

TestYoukuActivity.java 
Java代码    收藏代码
  1. package com.ljp.youku;  
  2.   
  3. import android.app.Activity;  
  4. import android.os.Bundle;  
  5. import android.view.View;  
  6. import android.view.View.OnClickListener;  
  7. import android.widget.ImageButton;  
  8. import android.widget.RelativeLayout;  
  9.   
  10. public class TestYoukuActivity extends Activity  
  11.       
  12.     private boolean areLevel2Showing trueareLevel3Showing true 
  13.     private RelativeLayout relate_level2, relate_level3;  
  14.   
  15.     private ImageButton home, menu;  
  16.   
  17.     @Override  
  18.     public void onCreate(Bundle savedInstanceState)  
  19.         super.onCreate(savedInstanceState);  
  20.         setContentView(R.layout.main);  
  21.   
  22.         findViews();  
  23.         setListener();  
  24.           
  25.      
  26.   
  27.     private void findViews()  
  28.         relate_level2 (RelativeLayout) findViewById(R.id.relate_level2);  
  29.         relate_level3 (RelativeLayout) findViewById(R.id.relate_level3);  
  30.         home (ImageButton) findViewById(R.id.home);  
  31.         menu (ImageButton) findViewById(R.id.menu);  
  32.      
  33.   
  34.     private void setListener()  
  35.         // 给大按钮设置点击事件  
  36.         home.setOnClickListener(new OnClickListener()  
  37.             @Override  
  38.             public void onClick(View v)  
  39.                 if (!areLevel2Showing)  
  40.                     MyAnimation.startAnimationsIn(relate_level2, 500);  
  41.                 else  
  42.                     if (areLevel3Showing)  
  43.                         MyAnimation.startAnimationsOut(relate_level2, 500500);  
  44.                         MyAnimation.startAnimationsOut(relate_level3, 5000);  
  45.                         areLevel3Showing !areLevel3Showing;  
  46.                     else  
  47.                         MyAnimation.startAnimationsOut(relate_level2, 5000);  
  48.                      
  49.                  
  50.                 areLevel2Showing !areLevel2Showing;  
  51.              
  52.         });  
  53.         menu.setOnClickListener(new OnClickListener()  
  54.             @Override  
  55.             public void onClick(View v)  
  56.                 if (!areLevel3Showing)  
  57.                     MyAnimation.startAnimationsIn(relate_level3, 500);  
  58.                 else  
  59.                     MyAnimation.startAnimationsOut(relate_level3, 5000);  
  60.                  
  61.                 areLevel3Showing !areLevel3Showing;  
  62.              
  63.         });  
  64.      
  65.   
  66. }  
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值