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. 4.1.1 A - Calendar(简单线性表)(日期查找)(数组应用)

    Description A calendar is a system for measuring time, from hours and minutes, to months and days, a ...

  2. 第二章 I - The 3n + 1 problem(2.4.2)

    这是一道很坑爹的题,一定注意输入的两个数的大小,并且不能简单的交换,因为在最后的输出的时候还需要将原来的数按照原来的顺序和大小,这就是为什么还得开辟两个值得原因 Description Problem ...

  3. fw:理解RESTful架构

    理解RESTful架构   作者: 阮一峰 日期: 2011年9月12日 越来越多的人开始意识到,网站即软件,而且是一种新型的软件. 这种"互联网软件"采用客户端/服务器模式,建立 ...

  4. 游戏服务器生成全局唯一ID的几种方法

    在服务器系统开发时,为了适应数据大并发的请求,我们往往需要对数据进行异步存储,特别是在做分布式系统时,这个时候就不能等待插入数据库返回了取自动id了,而是需要在插入数据库之前生成一个全局的唯一id,使 ...

  5. unity3d学习重点记录

    本文主要是记录在学习unity3d中遇到的重点功能的实现,以及一些API的使用方法.以便在以后使用到的时候查找. 1,给一个UIButton添加执行的事件 // Use this for initia ...

  6. 恶心的Oracle的if else if...

    出处:http://blog.sina.com.cn/s/blog_407d47e60100d8ig.html 前段时间写Oracle存储过程就遇到问题.原来写成这样if 1=2 then  null ...

  7. NSInteger 和 int 区别

      #if __LP64__ || (TARGET_OS_EMBEDDED && !TARGET_OS_IPHONE) || TARGET_OS_WIN32 || NS_BUILD_3 ...

  8. 跟我学 NHibernate (三)

    在使用 NHibernate 时,一定要将Mapping 映射文件,也就是 xml 文件的编译方式设置成 嵌入式,这是因为在 NHibernate 启动时,它会主动的到项目的启动目录中寻找 被设置为嵌 ...

  9. android网络判断

    //ConnectivityManager管理网络连接相关的操作 ConnectivityManager connectivityManager = (ConnectivityManager) con ...

  10. mysql中-e用法

    实际应用中,不仅可以先登陆mysql再使用,还可以在链接的时候进行sql操作,此时需要加参数-e 例: >mysql -hlocalhost -P8080 -uroot -p123456 -e' ...