All Projects → varunest → Sparkbutton

varunest / Sparkbutton

Licence: apache-2.0
Android library to create buttons with Twitter's heart like animation.

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to Sparkbutton

Lcformvalidation
Javascript based form validation library, third party library / framework agnostic.
Stars: ✭ 58 (-94.86%)
Mutual labels:  library
Vulkan2drenderer
Easy to use 2D rendering engine using Vulkan API as backend.
Stars: ✭ 60 (-94.69%)
Mutual labels:  library
Whisper
Whisper is a file-based time-series database format for Graphite.
Stars: ✭ 1,121 (-0.71%)
Mutual labels:  library
Cordova Plugin Device Motion
Apache Cordova Plugin device-motion
Stars: ✭ 58 (-94.86%)
Mutual labels:  library
Girc
💣 girc is a flexible IRC library for Go 👌
Stars: ✭ 59 (-94.77%)
Mutual labels:  library
Quantumgate
QuantumGate is a peer-to-peer (P2P) communications protocol, library and API written in C++.
Stars: ✭ 62 (-94.51%)
Mutual labels:  library
Material About Library
Makes it easy to create beautiful about screens for your apps
Stars: ✭ 1,099 (-2.66%)
Mutual labels:  library
Dotsloaderview
Simple dots loader view
Stars: ✭ 63 (-94.42%)
Mutual labels:  library
Goshare
Go Share your TimeSeries/NameSpace/KeyVal DataStore (using leveldb) over HTTP &/or ZeroMQ
Stars: ✭ 59 (-94.77%)
Mutual labels:  library
Cryptofin Solidity
A collection of Solidity libraries for building secure and gas-efficient smart contracts on Ethereum.
Stars: ✭ 62 (-94.51%)
Mutual labels:  library
React Gojs
GoJS React integration
Stars: ✭ 59 (-94.77%)
Mutual labels:  library
Ngx Tree Select
Angular select component with tree items
Stars: ✭ 59 (-94.77%)
Mutual labels:  library
Gena
Generic pseudo-templated containers for C. Written entirely in C89 with design inspired by the C++ STL. /// DOCS ARE SLIGHTLY OUTDATED, PROJECT IS STABLE AND STILL IN ACTIVE DEVELOPMENT
Stars: ✭ 61 (-94.6%)
Mutual labels:  library
Array view
Wrapper for references to array in C++.
Stars: ✭ 58 (-94.86%)
Mutual labels:  library
Roffildlibrary
Library for MQL5 (MetaTrader) with Python, Java, Apache Spark, AWS
Stars: ✭ 63 (-94.42%)
Mutual labels:  library
Thrift
Apache Thrift
Stars: ✭ 8,821 (+681.31%)
Mutual labels:  library
New Empty Python Project Base
The Perfect Python Project Template. Bored of coding anew the same thing for your new Python projects? Here is what you need. Click below on the "use this template" green button to start using it instantly. Rename the "project" folder and all references to this folder to customize your project name.
Stars: ✭ 60 (-94.69%)
Mutual labels:  library
Align
A general purpose application and library for aligning text.
Stars: ✭ 63 (-94.42%)
Mutual labels:  library
Best Of Web Python
🏆 A ranked list of awesome python libraries for web development. Updated weekly.
Stars: ✭ 1,118 (-0.97%)
Mutual labels:  library
Go Openssl
go-openssl is a small library wrapping the crypto/aes functions in a way the output is compatible to OpenSSL
Stars: ✭ 61 (-94.6%)
Mutual labels:  library

platform API License Android Arsenal Build Status

SparkButton

Highly customizable and lightweight library that allows you to create a button with animation effect similar to Twitter's heart animation.

Library supports OS on API 14 and above.

Showcase Video

Grab the above demo app from here :

Get it on Google Play

Dependency

Add it in your root build.gradle at the end of repositories:

allprojects {
	repositories {
		...
		maven { url "https://jitpack.io" }
	}
}

and then add dependency

dependencies {
	compile 'com.github.varunest:sparkbutton:1.0.6'
}

Usage

XML

<com.varunest.sparkbutton.SparkButton
            android:id="@+id/spark_button"
            android:layout_width="40dp"
            android:layout_height="40dp"
            app:sparkbutton_activeImage="@drawable/active_image"
            app:sparkbutton_inActiveImage="@drawable/inactive_image"
            app:sparkbutton_iconSize="40dp"
            app:sparkbutton_primaryColor="@color/primary_color"
            app:sparkbutton_secondaryColor="@color/secondary_color" />

Java

SparkButton button  = new SparkButtonBuilder(context)
                .setActiveImage(R.drawable.active_image)
                .setInActiveImage(R.drawable.inactive_image)
                .setDisabledImage(R.drawable.disabled_image)
                .setImageSizePx(getResources().getDimensionPixelOffset(R.dimen.button_size))
                .setPrimaryColor(ContextCompat.getColor(context, R.color.primary_color))
                .setSecondaryColor(ContextCompat.getColor(context, R.color.secondary_color))
                .build();

Attributes

<attr name="sparkbutton_iconSize" format="dimension|reference" />
<attr name="sparkbutton_activeImage" format="reference" />
<attr name="sparkbutton_disabledImage" format="reference" />
<attr name="sparkbutton_primaryColor" format="reference" />
<attr name="sparkbutton_secondaryColor" format="reference" />
<attr name="sparkbutton_pressOnTouch" format="boolean" />
<attr name="sparkbutton_animationSpeed" format="float" />

Documentation

To use SparkButton simply include XML script or build it using SparkButtonBuilder as stated above.

Various attributes that you can control are following:

Button Image and Colors

You can specify both active and inactive image of the button. If only active image is specified SparkButton will behave as a normal button, otherwise as a switch.

SparkButton takes two colors primary and secondary. (It is recommended that primary color is lighter than secondary for better results).

XML

app:sparkbutton_activeImage="@drawable/active_image"
app:sparkbutton_inActiveImage="@drawable/inactive_image"
app:sparkbutton_primaryColor="@color/primaryColor"
app:sparkbutton_secondaryColor="@color/secondaryColor"

Java

SparkButton button = new SparkButtonBuilder(context)
						.setActiveImage(R.drawable.active_image)
						.setInActiveImage(R.drawable.inactive_image)
						.setPrimaryColor(ContextCompat.getColor(context, R.color.primary_color))
						.setSecondaryColor(ContextCompat.getColor(context, R.color.secondary_color))
						.build();

Animation Speed

You can specify the fraction by which the animation speed should increase/decrease.

XML

app:sparkbutton_animationSpeed="1.5"

Java

sparkbutton.setAnimationSpeed(1.5f);

Button State

If you are using the SparkButton as a switch, you can check/uncheck the button

sparkButton.setChecked(true);

Event Listener

Simply call setEventListener to listen click events.

sparkButton.setEventListener(new SparkEventListener(){
		@Override
		void onEvent(ImageView button, boolean buttonState) {
			if (buttonState) {
				// Button is active
			} else {
				// Button is inactive
			}
		}
});

Play Animation

If you want to play animation regardless of click event execute following function:

sparkButton.playAnimation();

Advanced

  • There can be a situation when you don't want the button to scale download when pressed or consume touch. You can avoid this by calling the following function :

    sparkButton.pressOnTouch(false);
    
  • If you are using SparkButton between layout hierarchy, it can result in animation getting cropped. To avoid this cropping of the animation, set clipChildren and clipToPadding XML attribute of all the parent views to false.

  • You can view examples of few custom buttons in the sample app.

Inspiration

SparkButton was inspired by : https://github.com/frogermcs/LikeAnimation

Contribution

Any contributions, large or small, features, bug fixes are welcomed and appreciated. Use pull requests, they will be thoroughly reviewed and discussed.

Link Backs

If you are using this library in one of your projects and want it to be mentioned here in this ReadME, drop me a mail with project's url at [email protected].

License

Library falls under [Apache 2.0] (LICENSE.md)

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].