All Projects → jd-alexander → Likebutton

jd-alexander / Likebutton

Twitter's heart animation for Android

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to Likebutton

numix-icon-theme-square
Linux packaging for Numix Square
Stars: ✭ 143 (-95.19%)
Mutual labels:  icons
map-machine
Python renderer for OpenStreetMap with custom icons intended to display as many map features as possible
Stars: ✭ 82 (-97.24%)
Mutual labels:  icons
Awesome Icons
A curated list of awesome downloadable SVG/PNG/Font icon projects
Stars: ✭ 266 (-91.06%)
Mutual labels:  icons
vue-feather
Feather component for Vue.js.
Stars: ✭ 108 (-96.37%)
Mutual labels:  icons
reiconify
Convert SVG icons to React components eg.: https://ambar.li/reiconify/md.icons/#/Browse
Stars: ✭ 17 (-99.43%)
Mutual labels:  icons
healthicons
A collection of open source icons for public health projects.
Stars: ✭ 372 (-87.5%)
Mutual labels:  icons
haiku-icons
Haiku OS icons, exported to HVIF, SVG and PNG
Stars: ✭ 37 (-98.76%)
Mutual labels:  icons
Keyrune
Magic: the Gathering set symbol pictographic font
Stars: ✭ 272 (-90.86%)
Mutual labels:  icons
vue-icon
Maybe it is the smallest vue component that contains all the feather icons
Stars: ✭ 44 (-98.52%)
Mutual labels:  icons
Fluentui System Icons
Fluent System Icons are a collection of familiar, friendly and modern icons from Microsoft.
Stars: ✭ 3,413 (+14.68%)
Mutual labels:  icons
social-logos
A repository of all the social logos we use on WordPress.com
Stars: ✭ 110 (-96.3%)
Mutual labels:  icons
yaru-remix
My Novice approach for yaru-remix
Stars: ✭ 57 (-98.08%)
Mutual labels:  icons
coinicon
coinicon | stylized and simplified cryptocurrency icon
Stars: ✭ 18 (-99.4%)
Mutual labels:  icons
foundational-design-system-proto
A prototype for a foundational design system at Shopify
Stars: ✭ 82 (-97.24%)
Mutual labels:  icons
Suru Plus
Suru++ 25 — A cyberpunk, elegant, futuristic and Papirus-like third-party icons theme
Stars: ✭ 269 (-90.96%)
Mutual labels:  icons
graphicon
A Vue.js plugin/component to help you manage your icons seamlessly
Stars: ✭ 12 (-99.6%)
Mutual labels:  icons
Bitcoin-Icons
Icons made for Bitcoin applications, free to use.
Stars: ✭ 52 (-98.25%)
Mutual labels:  icons
Mdi Material Ui
Material-UI SvgIcon components for Material Design Icons.
Stars: ✭ 276 (-90.73%)
Mutual labels:  icons
Ltfinderbuttons
My Finder buttons collection for macOS.
Stars: ✭ 269 (-90.96%)
Mutual labels:  icons
Mega Doodles Pack
🔥 Big vector pack with hand-drawn doodles for presentations, social media, blog posts and so on
Stars: ✭ 258 (-91.33%)
Mutual labels:  icons

Like Button

JitPack Build Status License Android Arsenal

Like Button is a library that allows you to create a button with animation effects similar to Twitter's heart when you like something.

Icon animations


Table of Contents

  1. Gradle Dependency
    1. Repository
    2. Dependency
  2. Basic Usage
    1. Like Button XML
    2. Attributes
  3. Button State
  4. Like Event Listener
  5. Icon Types
  6. Icon Size
  7. Custom Icons
  8. Circle Color Config
  9. Dots Color Config
  10. Animation Size
  11. Inspiration
  12. Contribution
  13. License

Gradle Dependency

Repository

Add this in your root build.gradle file (not your module build.gradle file):

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

Dependency

Add this to your module's build.gradle file:

dependencies {
	...
	compile 'com.github.jd-alexander:LikeButton:0.2.3'
	}
}

Basic Usage

Like Button XML

To use this like button in your layout simply copy and paste the xml below. This provides the default heart button.

<com.like.LikeButton
            app:icon_type="heart"
            app:icon_size="25dp"
            android:id="@+id/star_button"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"/>

Attributes

There are several other attributes that can be used to configure the button's behaviour and appearance. They are shown below and will be explained in the sections that follow long with their java counterparts.

<com.like.LikeButton
app:icon_type="Star"
app:circle_start_color="@color/colorPrimary"
app:like_drawable="@drawable/thumb_on"
app:unlike_drawable="@drawable/thumb_off"
app:dots_primary_color="@color/colorAccent"
app:dots_secondary_color="@color/colorPrimary"
app:circle_end_color="@color/colorAccent"
app:icon_size="25dp"
app:liked="true"
app:anim_scale_factor="2"
app:is_enabled="false"
/>

Button State

To set the inital liked state of the button you simply use the setLiked functionality via XML or Java. This will show the button in the liked state with the drawable that you selected.

XML

app:liked="true"

Java

likeButton.setLiked(true);

You can also set if the button is to be enabled or disabled. Once disabled, the animation, listener or any other functionality of the button won't be triggered.

XML

app:is_enabled="false"

Java

likeButton.setEnabled(false);

Like Event Listener

To listen to events from your like button, simply implement the listener that's triggered once the button is tapped.

likeButton.setOnLikeListener(new OnLikeListener() {
            @Override
            public void liked(LikeButton likeButton) {

            }

            @Override
            public void unLiked(LikeButton likeButton) {

            }
        });

Icon Types

The libary is bundled with three icons that you can use. A heart,thumb and a star.

XML

To set the respective icon via xml simply use the word in the icon type attribute.

app:icon_type="heart"

Java

If you would like to set the icon via Java then simply call the set icon method on the button.

likeButton.setIcon(IconType.Star);

Icon Size

XML

To set the icon size via xml simply use this attribute

app:icon_size="20dp"

Java

If you are doing it programmatically you can set it with either the method for pixels or dp.

likeButton.setIconSizePx(40);
likeButton.setIconSizeDp(20);

Note, it's very important that the size of the button is set even if you are planning to use custom drawables as described below as the library uses this value to determine the width and height of the effects that occur when the button is tapped.


Custom Icons

XML

In order to use custom icons instead of the ones bundled with the library you simply set the drawables that represent the liked and unliked state of the button.

app:like_drawable="@drawable/thumb_on"
app:unlike_drawable="@drawable/thumb_off"

Java

likeButton.setLikeDrawable(heart_on);
likeButton.setUnlikeDrawable(heart_off);

likeButton.setUnlikeDrawableRes(R.drawable.heart_off);
likeButton.setLikeDrawableRes(R.drawable.heart_on);

Circle Color Config

If you watch the animation closely you will notice that there's a circle that begins from the center of the icon and and then it animates away from the center before the exploding dots animate. These colours can be changed to suit the theme of your icon.

XML

app:circle_start_color="@color/colorPrimary"
app:circle_end_color="@color/colorAccent"

Java

likeButton.setCircleEndColorRes(R.color.colorAccent);
likeButton.setCircleEndColorRes(R.color.colorPrimary);

Dots Color Config

The dots that represent the outer animation can be coloured also.

XML

app:dots_primary_color="@color/colorAccent"
app:dots_secondary_color="@color/colorPrimary"

Java

likeButton.setExplodingDotColorsRes(R.color.colorPrimary,R.color.colorAccent);

Animation Size

To change the size of the dots that also contributes to the size of the overall like button view you can use the animation scale factor attribute via XML or it's Java equivalent

XML

app:anim_scale_factor="2.5"

Java

likeButton.setAnimationScaleFactor(2);

Inspiration

This library was made by possible based on code and design inspiration from these sources:

https://github.com/frogermcs/LikeAnimation

https://github.com/lightsmeki/android_twitter_heart_animation_button

https://dribbble.com/shots/2416983-Twitter-Heart-Animation

Contribution

Please fork repository and contribute using pull requests.

Any contributions, large or small, major features, bug fixes, additional language translations, unit/integration tests are welcomed and appreciated but will be thoroughly reviewed and discussed.

License

Copyright 2016 Joel Dean

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
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].