Android 高仿优酷旋转菜单
这是一个很早版本的优酷菜单,效果挺不错的,实现起来也挺简单的。废话不说,直接上代码:
首先是xml文件:
<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"><!--一级菜单--> <RelativeLayout 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/id_menu" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerHorizontal="true" android:src="@drawable/icon_home" /></RelativeLayout><!--二级菜单--> <RelativeLayout android:id="@+id/level2" android:layout_width="180dp" android:layout_height="88dp" android:layout_alignParentBottom="true" android:layout_centerHorizontal="true" android:background="@drawable/level2"><ImageView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentBottom="true" android:layout_marginBottom="5dp" android:layout_marginLeft="5dp" android:src="@drawable/icon_search" /><ImageView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentBottom="true" android:layout_alignParentRight="true" android:layout_marginBottom="5dp" android:layout_marginRight="5dp" android:src="@drawable/icon_myyouku" /><ImageView android:id="@+id/id_menu2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerHorizontal="true" android:layout_marginBottom="5dp" android:src="@drawable/icon_menu" /></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:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentBottom="true" android:layout_marginBottom="6dp" android:layout_marginLeft="6dp" android:background="@drawable/channel1" /><ImageView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentBottom="true" android:layout_alignParentRight="true" android:layout_marginBottom="6dp" android:layout_marginRight="6dp" android:background="@drawable/channel5" /><ImageView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentBottom="true" android:layout_marginBottom="45dp" android:layout_marginLeft="28dp" android:background="@drawable/channel2" /><ImageView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentBottom="true" android:layout_alignParentRight="true" android:layout_marginBottom="45dp" android:layout_marginRight="28dp" android:background="@drawable/channel6" /><ImageView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentBottom="true" android:layout_marginBottom="75dp" android:layout_marginLeft="60dp" android:background="@drawable/channel3" /><ImageView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentBottom="true" android:layout_alignParentRight="true" android:layout_marginBottom="75dp" android:layout_marginRight="60dp" android:background="@drawable/channel7" /><ImageView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerHorizontal="true" android:background="@drawable/channel4" /></RelativeLayout> </RelativeLayout>
静态效果如下:
接下来实现关闭:
最后是activity中的实现:
public static int animCount=0;//记录当初动画数量; public static void closeMenu(RelativeLayout layout,int starttime) {//处理 菜单隐藏后,view还可以被点击的bug for (int i=0;i<layout.getChildCount();i++){layout.getChildAt(i).setEnabled(false);}RotateAnimation rotateAnimation = new RotateAnimation(0, -180,Animation.RELATIVE_TO_SELF, 0.5f,Animation.RELATIVE_TO_SELF, 1f);rotateAnimation.setDuration(500);rotateAnimation.setFillAfter(true);rotateAnimation.setStartOffset(starttime);rotateAnimation.setAnimationListener(new MyAnimationListeren());layout.startAnimation(rotateAnimation); }public static void openMenu(RelativeLayout layout,int starttime) {//处理 菜单显示后,view还可以被点击恢复 for (int i=0;i<layout.getChildCount();i++){layout.getChildAt(i).setEnabled(true);}RotateAnimation rotateAnimation = new RotateAnimation(-180, 0,Animation.RELATIVE_TO_SELF, 0.5f,Animation.RELATIVE_TO_SELF,1f);rotateAnimation.setDuration(500);rotateAnimation.setFillAfter(true);rotateAnimation.setStartOffset(starttime);rotateAnimation.setAnimationListener(new MyAnimationListeren());layout.startAnimation(rotateAnimation); } static class MyAnimationListeren implements Animation.AnimationListener{@Override public void onAnimationStart(Animation animation) {animCount++;}@Override public void onAnimationEnd(Animation animation) {animCount--;}@Override public void onAnimationRepeat(Animation animation) {} }
public void onClick(View v) {switch (v.getId()) {case R.id.id_menu:
//需要隐藏
int starttime=0;
if (ifLevel3Show) {
AnimUtil.closeMenu(layoutTHLevel,starttime);
ifLevel3Show = !ifLevel3Show;
starttime+=200; }
AnimUtil.closeMenu(layoutTLevel,starttime);
} else {
//需要显示
AnimUtil.openMenu(layoutTLevel); }
ifLevel2Show = !ifLevel2Show;
break;
case R.id.id_menu2:
//需要隐藏
AnimUtil.closeMenu(layoutTHLevel,0);
} else {
//需要显示
AnimUtil.openMenu(layoutTHLevel);
} ifLevel3Show = !ifLevel3Show; break; }}
if (AnimUtil.animCount!=0){//当前有动画在执行,直接返回,不进行操作 return;}
if (ifLevel3Show) {
if (AnimUtil.animCount!=0){//当前有动画在执行,直接返回,不进行操作 return;}
if (ifLevel2Show) {
demo链接:高仿优酷旋转菜单demo链接
Android 高仿优酷旋转菜单相关推荐
- android仿优酷菜单,Android编程实现仿优酷旋转菜单效果(附demo源码)
本文实例讲述了Android编程实现仿优酷旋转菜单效果.分享给大家供大家参考,具体如下: 首先,看下效果: 不好意思,不会制作动态图片,只好上传静态的了,如果谁会,请教教我吧. 首先,看下xml文件: ...
- my android tools优酷,Android自定义控件——仿优酷圆盘菜单
最近学习的时候,看见一份资料上教怎么写自定义控件,上面的示例用的是优酷早期版本的客户端,该客户端的菜单就是一个自定义的组件(现在的版本就不清楚有没有了,没下载过了),好吧,废话不多说,先上优酷的原型图 ...
- android仿疯狂猜图源码,Android开发实现高仿优酷的客户端图片左右滑动切换功能实例【附源码下载】...
本文实例讲述了Android开发实现高仿优酷的客户端图片左右滑动切换功能.分享给大家供大家参考,具体如下: 本例是用ViewPager去做的实现,支持自动滑动和手动滑动,不仅优酷网,实际上有很多商城和 ...
- 高仿优酷Android客户端图片左右滑动(自动切换)
本例是用ViewPager去做的实现,支持自动滑动和手动滑动,不仅优酷网,实际上有很多商城和门户网站都有类似的实现: 具体思路: 1. 工程中需要添加android-support-v4.jar,才能 ...
- Android 高仿 QQ5.0 侧滑菜单效果 自定义控件来袭
转载请标明出处:http://blog.csdn.net/lmj623565791/article/details/39257409,本文出自[张鸿洋的博客] 上一篇博客带大家实现了:Android ...
- android 双层旋转菜单,Android 高仿【优酷】圆盘旋转菜单的实现
目前,用户对安卓应用程序的UI设计要求越来越高,因此,掌握一些新颖的设计很有必要. 比如菜单,传统的菜单已经不能满足用户的需求. 其中优酷中圆盘旋转菜单的实现就比较优秀,这里我提供下我的思路及实现,仅 ...
- Android 高仿【优酷】圆盘旋转菜单的实现
目前,用户对安卓应用程序的UI设计要求越来越高,因此,掌握一些新颖的设计很有必要. 比如菜单,传统的菜单已经不能满足用户的需求. 其中优酷中圆盘旋转菜单的实现就比较优秀,这里我提供下我的思路及实现,仅 ...
- 完整视频播放器封装库,仿优酷
目录介绍 1.关于此视频封装库介绍 1.1 能够满足那些业务需求 1.2 对比同类型的库有哪些优势 2.关于使用方法说明 2.1 关于gradle引用说明 2.2 添加布局 2.3 最简单的视频播放器 ...
- Android 高仿QQ5.2双向側滑菜单DrawerLayout实现源代码
Android 高仿QQ5.2双向側滑菜单DrawerLayout实现源代码 左右側滑效果图 1.主页的实现 直接将DrawerLayout作为根布局,然后其内部第一个View为内容区域,第二个Vie ...
最新文章
- autoconfig.xml与antx.properties一级application.properties之间的关系
- 从1到10排序的C语言程序,C语言:用冒泡法从高到低排序10 个数,然后进行反排序...
- C++实现glut绘制点、直线、多边形、圆
- java中的CAS和原子类的实现
- 二叉树最近公共祖先相关题目(Leetcode题解-Python语言)
- 三星鸿蒙手机,被忽视的对手:三星的自研系统,已全球第一,成华为鸿蒙对手...
- MsSql2005如何进行自动定时备份数据库
- OpenBUGS抽样数据基本操作
- 从有到优:百度前端接入技术的升级之路
- 获取android手机步数,获取手机健康应用中的步数和距离
- html中th与thead的详细区别
- 华三交换机配置vrrp_VRRP原理与配置 华为、华三交换机,路由器
- AD软件——把原理图库 和 PCB元件库封装模型 关联起来
- 基于FPGA驱动DAC6004
- 浏览器 unload beforunload事件不触发
- Evernote 新搭档Evertracker,掌控自己的时间(视频)
- OMIM 表型和基因如何关联
- 弹性盒子布局flex
- EBS FOLDER文件夹报:FRM-41045和FRM-40105
- golang操作elasticsearch详解