CircularFloatingActionMenu在github上项目主页地址:https://github.com/oguzbilgener/CircularFloatingActionMenu

代码结构图:

测试代码:

package com.zzw.testcircularfloatingactionmenu;

import com.oguzdev.circularfloatingactionmenu.library.FloatingActionButton;
import com.oguzdev.circularfloatingactionmenu.library.FloatingActionMenu;
import com.oguzdev.circularfloatingactionmenu.library.FloatingActionMenu.MenuStateChangeListener;
import com.oguzdev.circularfloatingactionmenu.library.SubActionButton; import android.animation.ObjectAnimator;
import android.animation.PropertyValuesHolder;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.FrameLayout;
import android.widget.ImageView; /**
* 一个FloatingActionButton有一个FloatingActionMenu,FloatingActionMenu添加动画弹出的子菜单。
* FloatingActionButton的按钮点击事件将触发、弹出FloatingActionMenu中包含的子菜单。
* FloatingActionMenu使用attachTo方法附着在一个FloatingActionButton上。
* FloatingActionMenu在attachTo到一个FloatingActionButton后,两者之间发生关联。
* FloatingActionMenu在添加子菜单时候,首先需要一个SubActionButton.Builder,该SubActionButton.
* Builder通过setContentView(ImageView
* image).build()把一个ImageView创建生产一个SubActionButton ,
* 然后通过FloatingActionMenu.Builder的add方法把前面生成的SubActionButton添加进去。
*
* 按钮的旋转动画在onMenuOpened和onMenuClosed中做。
*
*/ public class MainActivity extends Activity { @Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); rightLowerButton(); leftCenterButton();
} // 右下角的菜单
private void rightLowerButton() {
final ImageView fabIconNew = new ImageView(this);
// 设置菜单按钮Button的图标
fabIconNew.setImageResource(R.drawable.ic_action_new_light);
final FloatingActionButton rightLowerButton = new FloatingActionButton.Builder(
this).setContentView(fabIconNew).build(); SubActionButton.Builder rLSubBuilder = new SubActionButton.Builder(this); ImageView rlIcon1 = new ImageView(this);
ImageView rlIcon2 = new ImageView(this);
ImageView rlIcon3 = new ImageView(this);
ImageView rlIcon4 = new ImageView(this);
// 设置弹出菜单的图标
rlIcon1.setImageResource(R.drawable.ic_launcher);
rlIcon2.setImageResource(R.drawable.ic_launcher);
rlIcon3.setImageResource(R.drawable.ic_launcher);
rlIcon4.setImageResource(R.drawable.ic_launcher); final FloatingActionMenu rightLowerMenu = new FloatingActionMenu.Builder(
this)
.addSubActionView(rLSubBuilder.setContentView(rlIcon1).build())
.addSubActionView(rLSubBuilder.setContentView(rlIcon2).build())
.addSubActionView(rLSubBuilder.setContentView(rlIcon3).build())
.addSubActionView(rLSubBuilder.setContentView(rlIcon4).build())
.attachTo(rightLowerButton).build(); rightLowerMenu.setStateChangeListener(new MenuStateChangeListener() { @Override
public void onMenuOpened(FloatingActionMenu menu) {
// 逆时针旋转90°
fabIconNew.setRotation(0);
PropertyValuesHolder pvhR = PropertyValuesHolder.ofFloat(
View.ROTATION, -90); ObjectAnimator animation = ObjectAnimator
.ofPropertyValuesHolder(fabIconNew, pvhR);
animation.start();
} @Override
public void onMenuClosed(FloatingActionMenu menu) {
// 顺时针旋转90°
fabIconNew.setRotation(-90);
PropertyValuesHolder pvhR = PropertyValuesHolder.ofFloat(
View.ROTATION, 0);
ObjectAnimator animation = ObjectAnimator
.ofPropertyValuesHolder(fabIconNew, pvhR);
animation.start(); }
});
} //左边中心位置的菜单
private void leftCenterButton() {
int redActionButtonSize = getResources().getDimensionPixelSize(
R.dimen.red_action_button_size);
int redActionButtonMargin = getResources().getDimensionPixelOffset(
R.dimen.action_button_margin);
int redActionButtonContentSize = getResources().getDimensionPixelSize(
R.dimen.red_action_button_content_size);
int redActionButtonContentMargin = getResources()
.getDimensionPixelSize(R.dimen.red_action_button_content_margin); int redActionMenuRadius = getResources().getDimensionPixelSize(
R.dimen.red_action_menu_radius);
int blueSubActionButtonSize = getResources().getDimensionPixelSize(
R.dimen.blue_sub_action_button_size);
int blueSubActionButtonContentMargin = getResources()
.getDimensionPixelSize(
R.dimen.blue_sub_action_button_content_margin); ImageView fabIconStar = new ImageView(this);
fabIconStar.setImageResource(R.drawable.star); // 设置菜单按钮Button的宽、高,边距
FloatingActionButton.LayoutParams starParams = new FloatingActionButton.LayoutParams(
redActionButtonSize, redActionButtonSize);
starParams.setMargins(redActionButtonMargin, redActionButtonMargin,
redActionButtonMargin, redActionButtonMargin);
fabIconStar.setLayoutParams(starParams); // 设置菜单按钮Button里面图案的宽、高,边距
FloatingActionButton.LayoutParams fabIconStarParams = new FloatingActionButton.LayoutParams(
redActionButtonContentSize, redActionButtonContentSize);
fabIconStarParams.setMargins(redActionButtonContentMargin,
redActionButtonContentMargin, redActionButtonContentMargin,
redActionButtonContentMargin); final FloatingActionButton leftCenterButton = new FloatingActionButton.Builder(
this).setContentView(fabIconStar, fabIconStarParams)
.setBackgroundDrawable(R.drawable.button_action_red_selector)
.setPosition(FloatingActionButton.POSITION_LEFT_CENTER)
.setLayoutParams(starParams).build(); SubActionButton.Builder lCSubBuilder = new SubActionButton.Builder(this);
lCSubBuilder.setBackgroundDrawable(getResources().getDrawable(
R.drawable.button_action_blue_selector)); //设置菜单中图标的参数
FrameLayout.LayoutParams blueContentParams = new FrameLayout.LayoutParams(
FrameLayout.LayoutParams.MATCH_PARENT,
FrameLayout.LayoutParams.MATCH_PARENT);
blueContentParams.setMargins(blueSubActionButtonContentMargin,
blueSubActionButtonContentMargin,
blueSubActionButtonContentMargin,
blueSubActionButtonContentMargin); lCSubBuilder.setLayoutParams(blueContentParams); //设置布局参数
FrameLayout.LayoutParams blueParams = new FrameLayout.LayoutParams(blueSubActionButtonSize,
blueSubActionButtonSize);
lCSubBuilder.setLayoutParams(blueParams); ImageView lcIcon1 = new ImageView(this);
ImageView lcIcon2 = new ImageView(this);
ImageView lcIcon3 = new ImageView(this);
ImageView lcIcon4 = new ImageView(this);
ImageView lcIcon5 = new ImageView(this); lcIcon1.setImageResource(R.drawable.ic_launcher);
lcIcon2.setImageResource(R.drawable.ic_launcher);
lcIcon3.setImageResource(R.drawable.ic_launcher);
lcIcon4.setImageResource(R.drawable.ic_launcher);
lcIcon5.setImageResource(R.drawable.ic_launcher); //setStartAngle(70).setEndAngle(-70)设置扩展菜单的位置
final FloatingActionMenu leftCenterMenu=new FloatingActionMenu.Builder(this)
.addSubActionView(lCSubBuilder.setContentView(lcIcon1, blueContentParams).build())
.addSubActionView(lCSubBuilder.setContentView(lcIcon2, blueContentParams).build())
.addSubActionView(lCSubBuilder.setContentView(lcIcon3, blueContentParams).build())
.addSubActionView(lCSubBuilder.setContentView(lcIcon4, blueContentParams).build())
.addSubActionView(lCSubBuilder.setContentView(lcIcon5, blueContentParams).build())
.setRadius(redActionMenuRadius).setStartAngle(70).setEndAngle(-70)
.attachTo(leftCenterButton).build();
} }

需要的具体xml见demo

点击后弧形展开的炫酷菜单--第三方开源-- CircularFloatingActionMenu(一)的更多相关文章

  1. (转载)android炫酷实用的开源框架(UI框架)

    可以实现一些场常用炫酷效果,包含android-lockpattern(图案密码解锁).Titanic(可以显示水位上升下降的TextView).Pull-to-Refresh.Rentals-And ...

  2. 炫酷实用的jQuery插件 涵盖菜单、按钮、图片

    新的一周开始了,今天我们要为大家分享一些全新的jQuery插件和HTML5/CSS3应用,这些jQuery插件不仅非常炫酷,而且还挺实用,这次的分享包含jQuery菜单.CSS3按钮已经多种图片特效, ...

  3. iOS开发——动画篇Swift篇&炫酷弹出菜单

    炫酷弹出菜单   这个是一个第三方按钮菜单组件,原版是使用Objective-C编写的名为AwesomeMenu的组件,地址是:https://github.com/levey/AwesomeMenu ...

  4. 炫酷实用的CSS3代码垂直手风琴菜单

    今天在微博上看到别人分享的代码,自己拿来自己保存着. 代码效果如下: 下面是源码: index.html <!DOCTYPE html> <html > <head> ...

  5. css3 炫酷下拉菜单

    <!doctype html> <html> <head> <meta charset="UTF-8"> <title> ...

  6. Android开发之炫酷MD风格

    文章转自:一点点征服的 http://www.cnblogs.com/ldq2016/p/5217590.html 安卓开发中非常炫的效果集合 这几天开发的时候,想做一些好看而且酷炫的特效,于是又开始 ...

  7. Photoshop和WPF双剑配合,打造炫酷个性的进度条控件

    现在如果想打造一款专业的App,UI的设计和操作的简便性相当重要.UI设计可以借助Photoshop或者AI等设计工具,之前了解到WPF设计工具Expression Blend可以直接导入PSD文件或 ...

  8. 程序猿必备的10款超炫酷HTML5 Canvas插件

    1.超炫酷HTML5 Canvas 3D旋转地球动画 这是一款基于HTML5 Canvas的3D地球模拟动画,动画以太空作为背景,地球在太空中旋转,同时我们也可以拖拽鼠标来从不同的角度观察地球.另外我 ...

  9. Qt之QSS(黑色炫酷)

    简述 Qt助手中有关于各种部件的QSS详细讲解,资源很丰富,请参考:Qt Style Sheets Examples. 黑色炫酷 - 一款漂亮的QSS风格. 之前博客中分享了很多关于Qt的样式效果,几 ...

随机推荐

  1. C Primer Plus(第五版)5

    第5章 运算符,表达式和语句 5.1 循环简单 程序清单 5.1 显示了一个示例程序,该程序做了一点算术运算来计算穿 9 码鞋的脚用英寸表示的长度.为了增加你对循环的理解,程序的第一版演示了不使用循环 ...

  2. div 滚动定位代码

    var thisheith;        $(function () {            var divid = '#14681-121320-197209';            $(di ...

  3. CodeForces 602E【概率DP】【树状数组优化】

    题意:有n个人进行m次比赛,每次比赛有一个排名,最后的排名是把所有排名都加起来然后找到比自己的分数绝对小的人数加一就是最终排名. 给了其中一个人的所有比赛的名次.求这个人最终排名的期望. 思路: 渣渣 ...

  4. Oracle VM VirtualBox 安装笔记

    [CentOS 6] 1.在官网下载VirtualBox-4.2-4.2.16_86992_el6-1.x86_64.rpm安装. 2.YUM安装kernel-devel包. 3.把用户加入vboxu ...

  5. CODESOFT中线条形状该如何绘制

    CODESOFT条码设计软件提供了一系列工具,可帮助您设计完美的标签.在CODESOFT进行标签设计时,经常会需要创建除条码,文本对象除外的一些对象,那就是形状对象.如线条.圆形.矩形等.通过下面的示 ...

  6. 使用Donut Caching和Donut Hole Caching在ASP.NET MVC应用中缓存页面

    Donut Caching是缓存除了部分内容以外的整个页面的最好的方式,在它出现之前,我们使用"输出缓存"来缓存整个页面. 何时使用Donut Caching 假设你有一个应用程序 ...

  7. Oracle对表解锁的操作

    1.查出被锁的表 SELECT  lpad(' ',decode(l.xidusn ,0,3,0))||l.oracle_username User_name, o.owner,o.object_na ...

  8. MySQL版本调研

    1引言 1.1 编写目的 本文的主要目的是通过对当前项目中使用的各种版本的数据库进行比较,分析各自特性和稳定程度,最终推荐合适的版本作为今后的标准数据库. 1.2 背景 当前,部门负责管理维护的现网使 ...

  9. SSH环境搭建步骤解析

    一.建立Java web project:AngelSSH 二.引入jar包,必要清单如下 2.1,Struts2 commons-fileupload  文件上传组件 commons-io   io ...

  10. 【HTML/XML 12】URI、URN、URL的联系和区别

    导读:在学习XML的时候,书中有很多个地方都提到URL等几个概念,再之前做项目的时候,重定向或是转发时,也用到了这个URL,在学习Ajax时,ajax破坏了统一资源定位(URN)都或多或少的接触到了这 ...