Android button which moves in eight direction.

Related tags

Button MovingButton
Overview

Moving Button

Android Arsenal Platform API License Join the chat at https://gitter.im/TheFinestArtist/MovingButton

Android button which moves in eight direction.

Preview

Preview

Sample Demo

You can download demo movie file here : demo.mov

It's also on Youtube:

Youtube

Sample Project

You can download the latest sample APK from this repo here: sample-release.apk

It's also on Google Play:

Get it on Google Play

Having the sample project installed is a good way to be notified of new releases.

Gradle Dependency (jcenter)

Easily reference the library in your Android projects using this dependency in your module's build.gradle file:

dependencies {
    compile 'com.thefinestartist:movingbutton:1.0.0'
}

Requirements

It supports Android API 3+.

It uses nineoldandroid for view animation.

Attrubutes

<!--Button Move Direction (Default : all)-->
<attr name="mb_move_direction">
    <enum name="all" value="0" />
    <enum name="horizontal_vertical" value="1" />
    <enum name="horizontal" value="2" />
    <enum name="vertical" value="3" />
    <enum name="still" value="4" />
</attr>

<!--Button Movement (Default : 0dp)-->
<!--Since DEFAULT value is ZERO, set up your button movement larger than zero.-->
<!--You can set up the movement as minus value-->
<attr name="mb_movement" format="dimension" />
<attr name="mb_movement_left" format="dimension" />
<attr name="mb_movement_right" format="dimension" />
<attr name="mb_movement_top" format="dimension" />
<attr name="mb_movement_bottom" format="dimension" />

<!--Button Event Offset (Default : 16dp for inner & 23dp for outer)-->
<!--Helps to calculate touch event from button-->
<attr name="mb_offset_inner" format="dimension" />
<attr name="mb_offset_outer" format="dimension" />

<!--Vibrate on button movement (Default : 0)-->
<!--android.permission.VIBRATE Permission required-->
<!--if you set the duration as 0, no Permission required!-->
<attr name="mb_event_volume" format="integer" />

<!--Play sound on button movement (Default : 0)-->
<attr name="mb_event_volume" format="integer" />

Layout Examples

<com.thefinestartist.movingbutton.MovingButton
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/moving_button"
    android:layout_width="100dp"
    android:layout_height="40dp"
    app:mb_move_direction="vertical"
    app:mb_event_volume="0"
    app:mb_vibration_duration="20"
    app:mb_movement="10dp" />

<com.thefinestartist.movingbutton.MovingButton
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/moving_button"
    android:layout_width="100dp"
    android:layout_height="40dp"
    app:mb_move_direction="all"
    app:mb_event_volume="50"
    app:mb_vibration_duration="20"
    app:mb_movementLeft="10dp"
    app:mb_movementRight="15dp"
    app:mb_movementTop="5dp"
    app:mb_movementBottom="20dp"
    app:mb_offset_inner="16dp"
    app:mb_offset_outer="23dp" />

Setter & Getter

// Move Direction
movingButton.getMoveDirection();
movingButton.setMoveDirection(MoveDirection.ALL);

// Movement (in Pixel dimension)
movingButton.getMovement();
movingButton.setMovement(10);
movingButton.getMovementLeft();
movingButton.setMovementLeft(10);
movingButton.getMovementRight();
movingButton.setMovementRight(10);
movingButton.getMovementTop();
movingButton.setMovementTop(10);
movingButton.getMovementBottom();
movingButton.setMovementBottom(10);

// Offset (in Pixel dimension)
movingButton.getOffSetInner();
movingButton.setOffSetInner(10);
movingButton.getOffSetOuter();
movingButton.setOffSetOuter(10);

// Vibration
movingButton.getVibrationDuration();
movingButton.setVibrationDuration(20);

// Volume
movingButton.getEventVolume();
movingButton.setEventVolume(50);

// Current Position
movingButton.getCurrentPosition();

Listener

public interface OnPositionChangedListener {
    // returns MotionEvent action and changed button position
    void onPositionChanged(int action, ButtonPosition position);
}

movingButton.setOnPositionChangedListener(new MovingButton.OnPositionChangedListener() {
    @Override
    public void onPositionChanged(int action, ButtonPosition position) {
        //your code here
    }
});

License

The MIT License (MIT)

Copyright (c) 2015 TheFinestArtist

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
You might also like...
A cute widget of Switch Button for  you to create beautiful and friendly UI.
A cute widget of Switch Button for you to create beautiful and friendly UI.

SwitchButton To get a quick preview, you can get Demo apk in Google Play or Directly download. This project provides you a convenient way to use and c

A simple Floating Action Button that shows an anchored Navigation View
A simple Floating Action Button that shows an anchored Navigation View

Floating Navigation View A simple Floating Action Button that shows an anchored Navigation View and was inspired by Menu Material Fixed created by Tom

A download button with pretty cool animation
A download button with pretty cool animation

ArrowDownloadButton A download button with pretty cool animation, this is an implemention of https://dribbble.com/shots/2012292-Download-Animation Enj

This is a Material Design loading button

This is a library project with a custom view that implements concept of Send Comment (https://dribbble.com/shots/1986254-Send-Comment-Shoppr) made by

A raised button that lowers down to 0dp of elevation
A raised button that lowers down to 0dp of elevation

RaiflatButton A raised button that lowers down to 0dp of elevation. From my blog post: https://rubensousa.github.io/2016/10/raiflatbutton It behaves l

A shopping cart button with a telescopic displacement rotation animation ...一个带伸缩位移旋转动画的购物车按钮
A shopping cart button with a telescopic displacement rotation animation ...一个带伸缩位移旋转动画的购物车按钮

AnimShopButton A shopping cart button with a telescopic displacement rotation animation ... 一个仿饿了么 带伸缩位移旋转动画的购物车按钮 注意,本控件非继承自ViewGroup,而是纯自定义View,实现的仿

Kotlin Expanding Floating Action button
Kotlin Expanding Floating Action button

Kotlin-Expanding-Floating-Action_button Home Screen As you can see there is only a siongle floating button with + icon Expanding Fab button When we cl

Floating Action Button But Moveable And Expandalbe

MeFab todo add the maven bacge here Floating Action Button but MOVEABLE and EXPA

➕ An efficient and beaufitul Multi Float action button library based on Twitter implemented in Jetpack Compose 🚀
➕ An efficient and beaufitul Multi Float action button library based on Twitter implemented in Jetpack Compose 🚀

Multi Float Action Button ➕ An efficient and beaufitul Multi Float action button library based on Twitter implemented in Jetpack Compose 🚀 Including

Comments
  • Add a Gitter chat badge to README.md

    Add a Gitter chat badge to README.md

    TheFinestArtist/MovingButton now has a Chat Room on Gitter

    @TheFinestArtist has just created a chat room. You can visit it here: https://gitter.im/TheFinestArtist/MovingButton.

    This pull-request adds this badge to your README.md:

    Gitter

    If my aim is a little off, please let me know.

    Happy chatting.

    PS: Click here if you would prefer not to receive automatic pull-requests from Gitter in future.

    opened by gitter-badger 0
  • ACTION_CANCEL

    ACTION_CANCEL

    Hi, check MovingButton line 155 there's a mistake i think

    case MotionEvent.**ACTION_CANCEL**: moveView(this, ButtonPosition.ORIGIN); positionChanged(**MotionEvent.ACTION_UP**, ButtonPosition.ORIGIN); break;

    opened by Th3CracKed 0
Owner
Leonardo Taehwan Kim
Leonardo Taehwan Kim
Button which is visible while user holds it. Main use case is controlling audio recording state (like in Telegram, Viber, VK).

HoldingButton Button which is visible while user holds it. Main use case is controlling audio recording state (like in Telegram, Viber, VK). Getting s

Artem Hluhovskyi 593 Nov 25, 2022
comtomize view submit button which you use for submit operation or download operation and so on.

This is library project with a custom view that implements concept of Submit Button (https://dribbble.com/shots/1426764-Submit-Button?list=likes&offse

ZhangLei 129 Feb 5, 2021
Android Circular Progress Button

?? Before using this library, read information below ?? This library is not more supported. If you want to add new feature or fix a bug, grab source

Dmytro Danylyk 5.6k Nov 22, 2022
Circle button widget for Android

DEPRECATED This library is deprecated and no new development is taking place. Consider using a FAB(Floating action button) instead. E.g. the Android D

Markus Hintersteiner 1.5k Nov 26, 2022
FButton - a flat button library for Android

FButton FButton is a custom Button of Android with "Flat UI" concept. FButton's design get inspiration from designmono. This library is very small and

Le Van Hoang 1.4k Nov 17, 2022
Button for android with animations for transition and error states.

Transition Button Android Preview Expand animation: Shake animation: Installation Gradle dependencies { implementation 'com.royrodriguez:transitionbu

Roy Rodriguez 133 Dec 1, 2022
[] Android floating action button

DEPRECATED Use the FloatingActionButton from the support library instead. FloatingActionButton Description Android floating action button which reacts

Oleksandr Melnykov 4k Nov 19, 2022
Floating Action Button for Android based on Material Design specification

FloatingActionButton Yet another library for drawing Material Design promoted actions. Features Support for normal 56dp and mini 40dp buttons. Customi

Zendesk 6.4k Nov 21, 2022
[] An Android library for an expandable button menu

ExpandableButtonMenu ExpandableButtonMenu is an Android library which implements an expandable button that can be used as a substitute of a fixed size

Lemon Labs 325 Nov 14, 2022
Android library providing an implementation of the Material Design Floating Action Button Speed Dial.

Android library providing an implementation of the Material Design Floating Action Button Speed Dial.

Sanyam Mehta 5 Aug 15, 2022