Code Monkey home page Code Monkey logo

androidlikebutton's Introduction

AndroidLikeButton

github gif

Platform API License

This library let you create a button with animation like twitter' heart , facebook like button in a simplest way

Gradle

Add the dependency

dependencies {
    ...
    implementation 'com.jackandphantom.android:androidlikebutton:1.2.0'
}

Basic Usage

AndroidLikeButton XML

In order to use AndroidLikeButton copy following xml code in your xml file.

 <com.jackandphantom.androidlikebutton.AndroidLikeButton
                android:layout_width="150dp"
                android:layout_height="150dp"
                android:layout_below="@+id/circular"
                android:layout_centerHorizontal="true"
                android:layout_marginTop="20dp"
                app:like_icon="@drawable/like_star"
                app:unlike_icon="@drawable/unlike_star"
                app:circle_startColor="#fcd229"
                app:circle_endColor="#f4ac1b"
                app:dot_color_1="#f5ce31"
                app:dot_color_2="#ed8128"
                >

Attributes

There are several attribute to configure AndroidLikeButton view, they are following

Like and Unlike image

To set like button and unlike button in your likebutton use :-

 <com.jackandphantom.androidlikebutton.AndroidLikeButton
       app:like="@drawable/like_star"  
        app:unlike_icon="@drawable/unlike_star"                                                  
  />

In Java you have several way to do it

   //Like Button
   androidLikeButton.setLikeIcon(Uri);
   androidLikeButton.setLikeIcon(Bitmap);
   androidLikeButton.setLikeIcon(ResId);
   
   //Unlike button
   
   androidLikeButton.setUnlikeIcon(Uri);
   androidLikeButton.setUnlikeIcon(Bitmap);
   androidLikeButton.setUnlikeIcon(ResId);

Circle

you can see the circle in animation so for changing the color of circle add the below code and you can also decide that circle should be appear or not in your animation.

Default of circle active is true.

 <com.jackandphantom.androidlikebutton.AndroidLikeButton
       app:circle_startColor="#fcd229"
       app:circle_endColor="#f4ac1b"
       app:circle_active="false"                                                  
  />

In Java

   
 androidLikeButton.setCircleColor(int color , int color);
 androidLikeButton.setCircleActive(boolean isActive);

Dot

you can see the Dot in animation so for changing the color of Dot add the below code and you can also decide that Dot should be appear or not in your animation.

Default of circle active is true.

 <com.jackandphantom.androidlikebutton.AndroidLikeButton
      app:dot_color_1="#f5ce31"
      app:dot_color_2="#ed8128"
      app:dot_active="false"                                                 
  />

In Java

   
 androidLikeButton.setDotColor(int color , int color);
 androidLikeButton.setDotActive(boolean isActive);

Like Button

In order to make AndroidLikeButton already liked because default implementation is make unlike image first then animate the view and convert it into like image so if you want to make already like in your implementation so just add below code.

Default value of liked = false.

 <com.jackandphantom.androidlikebutton.AndroidLikeButton
      app:liked="false"                                                 
  />

In Java

androidLikeButton.setCurrentlyLiked(boolean liked);

Like and Unlike Bitmap

If you need bitmap of like and unlike image then you can retrieve it by calling the below code java.

In Java

Bitmap likeBitmap = androidLikeButton.getLikeBitmap();
Bitmap unlikeBitmap = androidLikeButton.getUnlikeBitmap();

LICENCE

Copyright 2018 Ankit kumar

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.

Special Thanks to frogermcs

androidlikebutton's People

Contributors

sparrow007 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.