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. 针对android方法数64k的限制,square做出的努力。精简protobuf

    1.早期的Dalvik VM内部使用short类型变量来标识方法的id,dex限制了程序的最大方法数是65535,如果超过最大限制,无法编译,把dex.force.jumbo=true添加到proje ...

  2. 《Code Complete》ch.7 高质量的子程序

    WHAT? 子程序(routines)是为实现一个特定目的而编写的可被调用的方法或过程.在C++中是函数(function),在Java中是方法(method),在VB中是函数过程(function ...

  3. 1307: City Tour

    1307: City Tour Time Limit: 1 Sec  Memory Limit: 128 MB [Submit][Status][Web Board] Description Alic ...

  4. 【测试】模拟一个全表扫描的sql,对其进行优化走索引,并且将执行计划稳定到baseLine。

    ①创建表t3: SQL> create table t3 (id int); Table created. SQL; rows created. ②开启自动捕获并修改时间格式: SQL> ...

  5. No.002 Add Two Numbers

    Add Two Numbers Total Accepted: 160702 Total Submissions: 664770 Difficulty: Medium You are given tw ...

  6. 关于oracle中传过来的一个多id需要插入到数据库用,分格的存储过程

    create or replace procedure test ( jf_Id in nvarchar2, yf_id in nvarchar2 ) as v_length NUMBER := LE ...

  7. Java之注解

    package com.demo.test; import java.lang.annotation.Documented; import java.lang.annotation.ElementTy ...

  8. java中byte转换int时为何与0xff进行与运算

    在剖析该问题前请看如下代码 public static String bytes2HexString(byte[] b) {  String ret = "";  for (int ...

  9. 重拾qt

    最近公司又接了一个煤矿的项目,要写个小程序摘取数据,我是公司唯一c++程序员,本来搞ios搞好好的,现在又得重拾半年没摸得qt了.呵呵...呵呵呵. 这里只记录这次小程序的一些小的总结吧.. 1.中文 ...

  10. [Hibernate 1]Hibernate的环境搭建

    一.Hibernate是什么 直接使用JDBC操作数据库的步骤很繁琐,JDBC操作的是关系型数据库,而我们用JAVA开发程序,则使用面向对象的思想.Hibernate正是在这两种不同的模型之间建立关联 ...