优酷旋转菜单

移动开发
自定义view优酷菜单-其实就是旋转动画使用.

源码简介:自定义view优酷菜单-其实就是旋转动画使用.

源码效果:

源码片段:

  1. package com.kincai.zhuanti_coustom_view_youku_menu; 
  2.   
  3. import android.view.animation.Animation; 
  4. import android.view.animation.Animation.AnimationListener; 
  5. import android.view.animation.RotateAnimation; 
  6. import android.widget.RelativeLayout; 
  7.   
  8. /** 
  9.  *  
  10.  * @company KCS互联网有限公司 
  11.  *  
  12.  * @copyright KCS互联网有限公司版权所有 (c) 2014-2015 
  13.  *  
  14.  * @author kincai 
  15.  *  
  16.  * @description 动画工具 
  17.  *  
  18.  * @project Zhuanti_Coustom_View_youku_menu 
  19.  *  
  20.  * @package com.kincai.zhuanti_coustom_view_youku_menu 
  21.  *  
  22.  * @time 2015-7-24 下午7:18:13 
  23.  *  
  24.  */ 
  25. public class AnimUtil { 
  26.     /** 记录当前执行的动画数量 */ 
  27.     public static int animCount = 0
  28.   
  29.     /** 
  30.      * 显示或隐藏菜单 
  31.      *  
  32.      * @param rl 
  33.      *            view 
  34.      * @param startOffset 
  35.      *            延时时间 
  36.      * @param isShow 
  37.      *            isShow == true 显示 isShow == false 隐藏 
  38.      */ 
  39.     public static void showOrChoseMenu(RelativeLayout rl, int startOffset, 
  40.             boolean isShow) { 
  41.   
  42.         // RotateAnimation(float fromDegrees, float toDegrees, int pivotXType, 
  43.         // float pivotXValue, int pivotYType, float pivotYValue) 
  44.         // pivotXValue: 0-1 
  45.         /** 
  46.          * float fromDegrees, float toDegrees,角度从多少道多少 int pivotXType 
  47.          * x方向基于点的类型父控件或自己 float pivotXValue ,x方向基于的位置 
  48.          *  
  49.          */ 
  50.         RotateAnimation animation = null
  51.         if (isShow) { 
  52.             for (int i = 0; i < rl.getChildCount(); i++) { 
  53.                 rl.getChildAt(i).setEnabled(true); 
  54.             } 
  55.             animation = new RotateAnimation(-1800
  56.                     RotateAnimation.RELATIVE_TO_SELF, 0.5f, 
  57.                     RotateAnimation.RELATIVE_TO_SELF, 1); 
  58.         } else { 
  59.             for (int i = 0; i < rl.getChildCount(); i++) { 
  60.                 rl.getChildAt(i).setEnabled(false); 
  61.             } 
  62.             animation = new RotateAnimation(0, -180
  63.                     RotateAnimation.RELATIVE_TO_SELF, 0.5f, 
  64.                     RotateAnimation.RELATIVE_TO_SELF, 1); 
  65.         } 
  66.   
  67.         animation.setDuration(500); 
  68.         animation.setFillAfter(true);// 动画结束后保持当时的状态 就是动画结束的时候 就停止在那里不动了 
  69.         animation.setStartOffset(startOffset);// 延时 
  70.   
  71.         animation.setAnimationListener(new MyAnimationListener()); 
  72.   
  73.         rl.startAnimation(animation); 
  74.     } 
  75.   
  76.     /** 
  77.      * 动画监听 
  78.      */ 
  79.     static class MyAnimationListener implements AnimationListener { 
  80.         @Override 
  81.         public void onAnimationStart(Animation animation) { 
  82.             animCount++; 
  83.         } 
  84.   
  85.         @Override 
  86.         public void onAnimationEnd(Animation animation) { 
  87.             animCount--; 
  88.         } 
  89.   
  90.         @Override 
  91.         public void onAnimationRepeat(Animation animation) { 
  92.         } 
  93.   
  94.     } 

下载地址:http://down.51cto.com/data/2103330

责任编辑:倪明 来源: devstore
相关推荐

2009-12-16 10:06:51

互联网

2015-10-20 15:58:28

弹力菜单android源码

2017-06-16 09:39:32

优酷实践阿里云

2011-12-13 14:44:02

360开放平台

2014-06-09 14:44:44

Spark

2010-01-18 15:39:41

互联网

2015-08-20 17:22:03

京东

2015-03-31 17:28:32

2014-03-27 09:36:36

Spark

2013-12-03 16:47:50

优酷百度

2015-11-05 18:18:36

优酷

2021-06-09 08:30:52

CSS33D旋转视图3D动画

2012-12-28 14:58:31

Android优酷UI

2014-03-03 13:33:03

易传媒移动DSP

2016-05-12 13:31:38

优酷VR

2015-09-22 16:30:29

魅族

2015-02-26 16:29:56

2014-12-31 15:59:55

弹力菜单

2014-11-11 16:07:11

2012-03-12 17:24:23

优酷土豆合并
点赞
收藏

51CTO技术栈公众号