目前,用户对安卓应用程序的UI设计要求越来越高,因此,掌握一些新颖的设计很有必要.

比如菜单,传统的菜单已经不能满足用户的需求. 其中优酷中圆盘旋转菜单的实现就比较优秀,这里我提供下我的思路及实现,仅供参考.

该菜单共分里外三层导航菜单.可以依次从外向里关闭三层菜单,也可以反向打开,并且伴有圆盘旋转的动画效果

首先,看下效果:

以下是具体的代码及解释:

1. 菜单布局文件:

大家看到主要有三个RalativeLayout,就是大家看到的三层,但是关于图片的倾斜 是怎样实现的呢?实际上是个假象,图片是正放的,里面图像是倾斜的

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"xmlns:tools="http://schemas.android.com/tools"android:layout_width="fill_parent"android:layout_height="fill_parent" ><RelativeLayoutandroid:layout_width="100dip"android:layout_height="50dip"android:layout_alignParentBottom="true"android:layout_centerHorizontal="true"android:background="@drawable/level1" ><ImageButtonandroid:id="@+id/home"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_centerInParent="true"android:background="@drawable/icon_home" /></RelativeLayout><RelativeLayoutandroid:layout_width="180dip"android:layout_height="90dip"android:layout_alignParentBottom="true"android:layout_centerHorizontal="true"android:id="@+id/level2"android:background="@drawable/level2" ><ImageButtonandroid:id="@+id/search"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_alignParentBottom="true"android:layout_margin="10dip"android:background="@drawable/icon_search" /><ImageButtonandroid:id="@+id/menu"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_centerHorizontal="true"android:layout_margin="6dip"android:background="@drawable/icon_menu" /><ImageButtonandroid:id="@+id/myyouku"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_alignParentBottom="true"android:layout_alignParentRight="true"android:layout_margin="10dip"android:background="@drawable/icon_myyouku" /></RelativeLayout><RelativeLayoutandroid:layout_width="280dip"android:layout_height="140dip"android:layout_alignParentBottom="true"android:layout_centerHorizontal="true"android:id="@+id/level3"android:background="@drawable/level3" ><ImageButtonandroid:id="@+id/c1"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_alignParentBottom="true"android:layout_marginBottom="6dip"android:layout_marginLeft="12dip"android:background="@drawable/channel1" /><ImageButtonandroid:id="@+id/c2"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_above="@id/c1"android:layout_marginBottom="12dip"android:layout_marginLeft="28dip"android:background="@drawable/channel2" /><ImageButtonandroid:id="@+id/c3"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_above="@id/c2"android:layout_marginBottom="6dip"android:layout_marginLeft="8dip"android:layout_toRightOf="@id/c2"android:background="@drawable/channel3" /><ImageButtonandroid:id="@+id/c4"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_centerHorizontal="true"android:layout_margin="6dip"android:background="@drawable/channel4" /><ImageButtonandroid:id="@+id/c5"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_above="@+id/c6"android:layout_marginBottom="6dip"android:layout_marginRight="8dip"android:layout_toLeftOf="@+id/c6"android:background="@drawable/channel5" /><ImageButtonandroid:id="@+id/c6"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_above="@+id/c7"android:layout_marginBottom="12dip"android:layout_marginRight="28dip"android:layout_alignParentRight="true"android:background="@drawable/channel6" /><ImageButtonandroid:id="@+id/c7"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_alignParentBottom="true"android:layout_marginBottom="6dip"android:layout_marginRight="12dip"android:layout_alignParentRight="true"android:background="@drawable/channel7" /></RelativeLayout></RelativeLayout>

2. MainActivity;

import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageButton;
import android.widget.RelativeLayout;public class MainActivity extends Activity {private ImageButton home;private ImageButton menu;private RelativeLayout level2;private RelativeLayout level3;private boolean isLevel2Show = true;private boolean isLevel3Show = true;@Overridepublic void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_main);home = (ImageButton) findViewById(R.id.home);menu = (ImageButton) findViewById(R.id.menu);level2 = (RelativeLayout) findViewById(R.id.level2);level3 = (RelativeLayout) findViewById(R.id.level3);menu.setOnClickListener(new OnClickListener() {@Overridepublic void onClick(View v) {if(isLevel3Show){//隐藏3级导航菜单MyAnimation.startAnimationOUT(level3, 500, 0);}else {//显示3级导航菜单MyAnimation.startAnimationIN(level3, 500);}isLevel3Show = !isLevel3Show;}});home.setOnClickListener(new OnClickListener() {@Overridepublic void onClick(View v) {if(!isLevel2Show){//显示2级导航菜单MyAnimation.startAnimationIN(level2, 500);} else {if(isLevel3Show){//隐藏3级导航菜单MyAnimation.startAnimationOUT(level3, 500, 0);//隐藏2级导航菜单MyAnimation.startAnimationOUT(level2, 500, 500);isLevel3Show = !isLevel3Show;}else {//隐藏2级导航菜单MyAnimation.startAnimationOUT(level2, 500, 0);}}isLevel2Show = !isLevel2Show;}});}}

3. 自定义动画类MyAnimation:

import android.view.View;
import android.view.ViewGroup;
import android.view.animation.Animation;
import android.view.animation.Animation.AnimationListener;
import android.view.animation.RotateAnimation;public class MyAnimation {//入动画public static void startAnimationIN(ViewGroup viewGroup, int duration){for(int i = 0; i < viewGroup.getChildCount(); i++ ){viewGroup.getChildAt(i).setVisibility(View.VISIBLE);//设置显示viewGroup.getChildAt(i).setFocusable(true);//获得焦点viewGroup.getChildAt(i).setClickable(true);//可以点击}Animation animation;/*** 旋转动画* RotateAnimation(fromDegrees, toDegrees, pivotXType, pivotXValue, pivotYType, pivotYValue)* fromDegrees 开始旋转角度* toDegrees 旋转到的角度* pivotXType X轴 参照物* pivotXValue x轴 旋转的参考点* pivotYType Y轴 参照物* pivotYValue Y轴 旋转的参考点*/animation = new RotateAnimation(-180, 0, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 1.0f);animation.setFillAfter(true);//停留在动画结束位置animation.setDuration(duration);viewGroup.startAnimation(animation);}//出动画public static void startAnimationOUT(final ViewGroup viewGroup, int duration , int startOffSet){Animation animation;animation = new RotateAnimation(0, -180, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 1.0f);animation.setFillAfter(true);//停留在动画结束位置animation.setDuration(duration);animation.setStartOffset(startOffSet);animation.setAnimationListener(new AnimationListener() {@Overridepublic void onAnimationStart(Animation animation) {// TODO Auto-generated method stub}@Overridepublic void onAnimationRepeat(Animation animation) {// TODO Auto-generated method stub}@Overridepublic void onAnimationEnd(Animation animation) {for(int i = 0; i < viewGroup.getChildCount(); i++ ){viewGroup.getChildAt(i).setVisibility(View.GONE);//设置显示viewGroup.getChildAt(i).setFocusable(false);//获得焦点viewGroup.getChildAt(i).setClickable(false);//可以点击}}});viewGroup.startAnimation(animation);}
}

这样,一个高仿优酷三级导航圆盘旋转菜单就完成了.,以后完全可以借鉴这些优秀的UI设计,甚至根据新的需求,可以做出更好的UI.

源代码下载地址

http://download.csdn.net/detail/t12x3456/4518220

Android 高仿【优酷】圆盘旋转菜单的实现相关推荐

  1. Android 高仿优酷旋转菜单

    这是一个很早版本的优酷菜单,效果挺不错的,实现起来也挺简单的.废话不说,直接上代码: 首先是xml文件: <RelativeLayout xmlns:android="http://s ...

  2. my android tools优酷,Android自定义控件——仿优酷圆盘菜单

    最近学习的时候,看见一份资料上教怎么写自定义控件,上面的示例用的是优酷早期版本的客户端,该客户端的菜单就是一个自定义的组件(现在的版本就不清楚有没有了,没下载过了),好吧,废话不多说,先上优酷的原型图 ...

  3. android仿疯狂猜图源码,Android开发实现高仿优酷的客户端图片左右滑动切换功能实例【附源码下载】...

    本文实例讲述了Android开发实现高仿优酷的客户端图片左右滑动切换功能.分享给大家供大家参考,具体如下: 本例是用ViewPager去做的实现,支持自动滑动和手动滑动,不仅优酷网,实际上有很多商城和 ...

  4. 高仿优酷Android客户端图片左右滑动(自动切换)

    本例是用ViewPager去做的实现,支持自动滑动和手动滑动,不仅优酷网,实际上有很多商城和门户网站都有类似的实现: 具体思路: 1. 工程中需要添加android-support-v4.jar,才能 ...

  5. Android高仿QQ及微信底部菜单的多种实现方式【附源码地址】

    第一种方式:侧滑菜单+底部导航,已经实现聊天,表情,图片,位置,语音等信息的发送. 看效果: 下载地址:https://github.com/HuTianQi/QQ 第二种方式:Fragment+Po ...

  6. Android高仿qq及微信底部菜单的几种实现方式

    文章目录 导航类型 第一种方式:侧滑菜单+底部导航,已经实现聊天,表情,图片,位置,语音等信息的发送. 第二种方式:Fragment+PopupWindow仿QQ空间最新版底部菜单栏 第三种方式:Fr ...

  7. android 双层旋转菜单,Android 高仿【优酷】圆盘旋转菜单的实现

    目前,用户对安卓应用程序的UI设计要求越来越高,因此,掌握一些新颖的设计很有必要. 比如菜单,传统的菜单已经不能满足用户的需求. 其中优酷中圆盘旋转菜单的实现就比较优秀,这里我提供下我的思路及实现,仅 ...

  8. 完整视频播放器封装库,仿优酷

    目录介绍 1.关于此视频封装库介绍 1.1 能够满足那些业务需求 1.2 对比同类型的库有哪些优势 2.关于使用方法说明 2.1 关于gradle引用说明 2.2 添加布局 2.3 最简单的视频播放器 ...

  9. android仿优酷菜单,Android编程实现仿优酷旋转菜单效果(附demo源码)

    本文实例讲述了Android编程实现仿优酷旋转菜单效果.分享给大家供大家参考,具体如下: 首先,看下效果: 不好意思,不会制作动态图片,只好上传静态的了,如果谁会,请教教我吧. 首先,看下xml文件: ...

最新文章

  1. TensorFlow平台搭建
  2. 文化创意企业纷纷跨界融合,软件资产管理奠定安全基础
  3. 【 Linux 】创建、查看、删除文件
  4. 广度优先遍历算法-01寻找制高点问题
  5. [Spring5]AOP底层原理
  6. 【CCF】201803-1 跳一跳
  7. JS:ES6-2 const 关键字
  8. 怎样识别一个人是否可交
  9. 怎么才能取消和实现XP/windows 7自动登陆
  10. Leetcode之通配符匹配
  11. C#如何实现一个简单的流程图设计器
  12. 人物抠图(Photoshop技巧系列)
  13. JAVA毕设项目宠物店管理系统设计与实现(Vue+Mybatis+Maven+Mysql+sprnig+SpringMVC)
  14. 公共数据 | CnOpenData中国90座城市建筑物屋顶矢量数据集
  15. geo差异表达分析_GEO2R差异表达分析软件
  16. 记录一下通过QQ发送apk安装失败原因。
  17. 数据库原理第二章测验(标黑的为答案)
  18. Java TDD介绍-1
  19. Virustotal——md5转sha256
  20. xdebug3的配置文件不生效,提示waiting for incoming connection with ide key ‘xxx‘

热门文章

  1. 数学基础-小波变换的原理及其应用
  2. Windows系统 Apple 注销账户 Revoke Token
  3. 如何让php自动进行二级域名泛解析
  4. 国产C919大型客机已经接到235架飞机定单
  5. 最小二乘法求解傅里叶级数系数
  6. 【干货人生篇】过早优化的陷阱!
  7. 机场航拍图像检测软件(Python+YOLOv5深度学习模型+清新界面)
  8. package_josn解释
  9. 通信原理笔记—增量调制(∆M)
  10. android uevent_open_socket,android 6.0 healthd vold接收uevent