Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

https://github.com/rjsvieira/floatingMenu

An orbit-like action button
https://github.com/rjsvieira/floatingMenu

Last synced: 1 day ago
JSON representation

An orbit-like action button

Lists

README

        

# FloatingMenu

[![Android Arsenal](https://img.shields.io/badge/Android%20Arsenal-FloatingMenu-brightgreen.svg?style=flat)](https://android-arsenal.com/details/1/5697)
![Current Version](https://img.shields.io/badge/Current%20Version-1.3.0-brightgreen.svg)
[![](https://jitpack.io/v/rjsvieira/floatingMenu.svg)](https://jitpack.io/#rjsvieira/floatingMenu)
![Minimum SDK](https://img.shields.io/badge/minSdkVersion%20-15-blue.svg)

Include in your project

In your root/build.gradle

```groovy
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
```

In your app/build.gradle

```groovy
dependencies {
compile 'com.github.rjsvieira:floatingMenu:1.3.0'
}
```

Customization

The FloatingMenuButton central image allows the user to give it any appearance he desires.

The user can also specify a ClickListener and add it to it. Thanks to the FloatingMenuButton's composite clickListener, it will not override the animation toggling.


The FloatingMenuButton only accepts FloatingSubButton children.

Like the FloatingMenuButton, the FloatingSubButton can be configured to have a specific background and a ClickListener for interaction.
The following XML file specifies the example on the radial gifs :



```xml

```

Adding a FloatingSubButton programmatically

You can add a FloatingSubButton programmatically using the following lines of code.

```java
FloatingSubButton floatingSubButton = new FloatingSubButton(this); // create the button
floatingSubButton.setBackground(getDrawable(R.drawable.four)); // specify a custom background
```
And add it to the parent FloatingButton by either specifying layout parameters or assuming default parameters (as default, the layoutParameters for the first button on the list will be considered)
```java
floatingButton.addFloatingSubButton(floatingSubButton, customLayoutParameters);
```
or
```java
floatingButton.addFloatingSubButton(floatingSubButton);
```


Attribute configuration list

| Attribute | Type | Default | Default |
| ------------- |:-------------:| :-----| :------ |
| startAngle | int | The starting angle for button disposition | 0 |
| endAngle | int | The ending angle for button disposition | 180 |
| radius | int | The distance between the central button and its children | 100(dp) |
| movementStyle | MovementStyle (Enumerator) | Configures whether the user can or not drag the FloatingMenu around | MovementStyle.FREE |
| animationType | AnimationType (Enumerator) | The open/close animation for FloatingMenuButton | AnimationType.EXPAND |
| openingDuration | int | The opening duration, in milliseconds, of the animation | 500 |
| closingDuration | int | The closing duration, in milliseconds, of the animation | 500 |
| lagBetweenItems | int | The lag duration between animating items. Affects only AnimationType.EXPAND | 100 |
| openingInterpolator | Interpolator | The opening interpolator. Allows different rythms on the animations| OvershootInterpolator |
| closingInterpolator | Interpolator | The closing interpolator. Allows different rythms on the animations | AccelerateDecelerateInterpolator |
| shouldRotate | boolean | Specify whether the items should rotate while animating. Available only in AnimationType.EXPAND | true |
| shouldFade | boolean | Specify whether the items should fade while animating. Available only in AnimationType.EXPAND | true |
| shouldScale | boolean | Specify whether the items should scale while animating. Available only in AnimationType.EXPAND | true |

FloatingMenuButton State Change Listener

You can track whether the FloatingMenuButton is in open or closed status

```java
public interface FloatingMenuButtonStateChangeListener {

void onMenuOpened(FloatingMenuButton menu);

void onMenuClosed(FloatingMenuButton menu);

}
```

FloatingMenuButton Animation Handler (Wrapper)

You can configure the FloatingMenuButton programmatically rather than xml, specifying and settings its variables.
Consider the following example :

```java
floatingButton = (FloatingMenuButton) findViewById(R.id.my_floating_button);
floatingButton.setStartAngle(0)
.setEndAngle(360)
.setAnimationType(AnimationType.EXPAND)
.setMovementStyle(MovementStyle.STICKED_TO_SIDES);
floatingButton.getAnimationHandler()
.setOpeningAnimationDuration(500)
.setClosingAnimationDuration(200)
.setLagBetweenItems(0)
.setOpeningInterpolator(new FastOutSlowInInterpolator())
.setClosingInterpolator(new FastOutLinearInInterpolator())
.shouldFade(true)
.shouldScale(true)
.shouldRotate(false);
```