以前都是说每逢佳节倍思亲,现在的工作状态是每到周末倍亲切,年底真的是加班加的没完没了的,也没时间写博客,也没时间学习,周末闲来无事看到一个比较有意思的旋转菜单,没事自己实战了一下感觉还不错,代码倒是没什么,主要是有两个技术点,一个就是布局文件,第二个就是动画旋转,关于布局文件是仁者见仁智者见智,只能自己研究,动画的话之前写过这方面的文章有兴趣的可以看下本人之前的博客,开始正题吧:

基础布局

先看下要实现的效果吧:

下面的主要是三个图片,一个半圆,两个版圆环,最外面的是三级菜单,中间的是二级菜单;

一级菜单布局:

   <RelativeLayout
android:id="@+id/menuFirst"
android:layout_width="100dp"
android:layout_height="50dp"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:background="@drawable/menu1" > <ImageView
android:id="@+id/icon_home"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:background="@drawable/icon_home" />
</RelativeLayout>

二级菜单布局:

    <RelativeLayout
android:id="@+id/menuSecond"
android:layout_width="170dp"
android:layout_height="90dp"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:background="@drawable/menu2" > <ImageView
android:id="@+id/icon_search"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_margin="8dp"
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_center"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_margin="8dp"
android:background="@drawable/icon_center" />
</RelativeLayout>

三级菜单布局,这个布局的时候需要注意的是左边的三个图片设置完之后,设置的是对称方向的最底部的一个图片,以此为依据搞定其他两个图标:

  <RelativeLayout
android:id="@+id/menuThird"
android:layout_width="270dp"
android:layout_height="140dp"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:background="@drawable/menu3" > <ImageView
android:id="@+id/channel1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_marginBottom="8dp"
android:layout_marginLeft="8dp"
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="8dp"
android:layout_marginLeft="16dp"
android:background="@drawable/channel2" /> <ImageView
android:id="@+id/channel3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="@id/channel2"
android:layout_alignLeft="@id/channel2"
android:layout_marginBottom="8dp"
android:layout_marginLeft="30dp"
android:background="@drawable/channel3" /> <ImageView
android:id="@+id/channel4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="5dp"
android:background="@drawable/channel4" /> <ImageView
android:id="@+id/channel7"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_marginBottom="8dp"
android:layout_marginRight="8dp"
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="8dp"
android:layout_marginRight="20dp"
android:background="@drawable/channel6" /> <ImageView
android:id="@+id/channel5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="@id/channel6"
android:layout_alignRight="@id/channel6"
android:layout_marginBottom="8dp"
android:layout_marginRight="30dp"
android:background="@drawable/channel5" />
</RelativeLayout>

实现Demo

主要实现的主要就是两个按钮,一个按钮式最底层的按钮,一个是二级菜单的按钮:

		homeView = (ImageView) findViewById(R.id.icon_home);
menuView = (ImageView) findViewById(R.id.icon_menu);
menuFirst = (RelativeLayout) findViewById(R.id.menuFirst);
menuSecond = (RelativeLayout) findViewById(R.id.menuSecond);
menuThird = (RelativeLayout) findViewById(R.id.menuThird);
homeView.setOnClickListener(this);
menuView.setOnClickListener(this);

两个按钮的点击事件:

	@Override
public void onClick(View v) {
// TODO Auto-generated method stub
switch (v.getId()) {
case R.id.icon_home:
if (isSecond) {
MyHelper.StartAninationOut(menuSecond,500,200);
if (isThird) {
MyHelper.StartAninationOut(menuThird,500,300);
isThird=false;
}
}else {
MyHelper.StartAninationIn(menuSecond,500,300);
}
isSecond=!isSecond;
break;
case R.id.icon_menu:
if (isThird) {
MyHelper.StartAninationOut(menuThird,500,200);
isThird=false;
}else {
MyHelper.StartAninationIn(menuThird,500,200);
isThird=true;
}
break;
default:
break;
}
}

 两个按钮都有点击点击事件,封装一个可以主要就是淡入和淡出的效果:

public class MyHelper {

	public static void StartAninationIn(RelativeLayout layout,long duratoin,long offset) {
// TODO Auto-generated method stub
RotateAnimation rotateAnimation=new RotateAnimation(180, 360, layout.getWidth()/2, layout.getHeight());
rotateAnimation.setDuration(duratoin);
rotateAnimation.setFillAfter(true);//保持旋转之后的状态
rotateAnimation.setStartOffset(offset);//延迟加载时间
layout.startAnimation(rotateAnimation);
} public static void StartAninationOut(RelativeLayout layout,long duratoin,long offset) {
// TODO Auto-generated method stub
RotateAnimation rotateAnimation=new RotateAnimation(0, 180, layout.getWidth()/2, layout.getHeight());
rotateAnimation.setDuration(duratoin);
rotateAnimation.setFillAfter(true);
rotateAnimation.setStartOffset(offset);
layout.startAnimation(rotateAnimation);
} }

 最后看下效果图:

链接: http://pan.baidu.com/s/1jGh3Qse 密码: wilw

Android UI-底部旋转菜单栏的更多相关文章

  1. [转]Android UI:看看Google官方自定义带旋转动画的ImageView-----RotateImageView怎么写(附 图片淡入淡出效果)

    http://blog.csdn.net/yanzi1225627/article/details/22439119 众所周知,想要让ImageView旋转的话,可以用setRotation()让其围 ...

  2. Android UI:看看Google官方自定义带旋转动画的ImageView-----RotateImageView怎么写(附 图片淡入淡...)

    众所周知,想要让ImageView旋转的话,可以用setRotation()让其围绕中心点旋转,但这个旋转是不带动画的,也就是旋转屏幕时图片噌的一下就转过去了,看不到旋转的过程,此UI体验不大好,为此 ...

  3. Android UI设计

    Android UI设计--PopupWindow显示位置设置 摘要: 当点击某个按钮并弹出PopupWindow时,PopupWindow左下角默认与按钮对齐,但是如果PopupWindow是下图的 ...

  4. GitHub上受欢迎的Android UI Library

    GitHub上受欢迎的Android UI Library 内容 抽屉菜单 ListView WebView SwitchButton 按钮 点赞按钮 进度条 TabLayout 图标 下拉刷新 Vi ...

  5. Android UI相关开源项目库汇总

    最近做了一个Android UI相关开源项目库汇总,里面集合了OpenDigg 上的优质的Android开源项目库,方便移动开发人员便捷的找到自己需要的项目工具等,感兴趣的可以到GitHub上给个st ...

  6. 各种Android UI开源框架 开源库

    各种Android UI开源框架 开源库 转 https://blog.csdn.net/zhangdi_gdk2016/article/details/84643668 自己总结的Android开源 ...

  7. Android UI性能测试——使用 Gfxinfo 衡量性能

    Android官方文档翻译 原文地址:https://developer.android.com/training/testing/performance参考:https://www.jianshu. ...

  8. iPhone/iPad/Android UI尺寸规范 UI尺寸规范,UI图标尺寸,UI界面尺寸,iPhone6尺寸,iPhone6 Plus尺寸,安卓尺寸,iOS尺寸

    iPhone/iPad/Android UI尺寸规范 UI尺寸规范,UI图标尺寸,UI界面尺寸,iPhone6尺寸,iPhone6 Plus尺寸,安卓尺寸,iOS尺寸 iPhone界面尺寸 设备 分辨 ...

  9. Android应用底部导航栏(选项卡)实例

    现在很多android的应用都采用底部导航栏的功能,这样可以使得用户在使用过程中随意切换不同的页面,现在我采用TabHost组件来自定义一个底部的导航栏的功能. 我们先看下该demo实例的框架图: 其 ...

随机推荐

  1. 【知了堂学习笔记】java 正则表达式

    本文参考网络上面别人的博客知识产出 正则表达式基础 1.句号 假设你想要找出三个字母的单词,而且这些单词必须以“t”字母开头,以“n”字母结束.另外,假设有一本英文字典,你可以用正则表达式搜索它的全部 ...

  2. Ubuntu16.04 下的网易云出现网络异常、无法播放,界面无响应问题的统一解决

    能够在Linux系统下体验到原生界面的网易云音乐是件不错的事情,但是它总是经常性的出现网络异常,界面无响应的问题 为了听歌的体验,进行深入探究: 首先通过终端启用网易云音乐:sudo netease- ...

  3. Java 集合补充

    集合大致可以分List,Set,Queue,Map四种体系. 集合和数组不一样,数组元素可以是基本类型的值,也可以是对象(的引用变量),集合里只能保存对象(的引用变量). 访问:如果访问List集合中 ...

  4. 【Performance】chrome调试面板

    本篇文章以chrome版本67.0.3396.99为例,说明性能方面的调试.

  5. HTTP首部字段

    HTTP首部由首部字段名和首部字段值组成,以逗号隔开.如果首部出现重复,有些浏览器优先处理第一个出现的首部,有些优先处理后者. 主要分为四大类 通用首部字段 请求首部字段 响应首部字段 实体首部字段 ...

  6. dll文件反编译,c#、vb动态库反编译

    最近开发遇到一个项目,对方提供一个c#编写的动态库,图片处理需要调用该动态库方法,发现一张图片处理起来需要5s时间,对方无法提供有效解决手段,抱着试一试的想法反编译的对方的动态库,发现其中问题. 一下 ...

  7. bzoj 1176

    收获: 1.min, max, sum, 属于判定,等询问是”对象对答案贡献独立“,即不需要其他对象就了能更新答案,并保证只要所有对象更新过答案,那么该答案就是正确的.大概这就是所谓的”修改独立“. ...

  8. QCon大会上推荐阅读的10本书

    QCon北京2014大会将于4月25-27日在北京国际会议中心盛大开幕.QCon是由@InfoQ 主办的全球顶级技术盛会.在此次盛会中,现场将有@人民邮电出版社-信息技术分社 主办的现场扫描二维码赠书 ...

  9. ARM FPGA Extended Memory Interface

    Connect a ARM Microcontroller to a FPGA using its Extended Memory Interface (EMI) http://elinux.org/ ...

  10. C#线程安全的那些事

    还是上一次,面试的时候提到了C#线程安全的问题,当时回答的记不太清了,大概就是多线程同是调用某一个函数时可能会照成数据发生混乱,运行到最后发现产生的结果或数据并不是自己想要的,或是跨线程调用属性或方法 ...