{"id":13492551,"url":"https://github.com/jd-alexander/LikeButton","last_synced_at":"2025-03-28T10:32:23.962Z","repository":{"id":39618000,"uuid":"48503645","full_name":"jd-alexander/LikeButton","owner":"jd-alexander","description":"Twitter's heart animation for Android","archived":false,"fork":false,"pushed_at":"2024-01-26T16:26:58.000Z","size":367,"stargazers_count":3016,"open_issues_count":16,"forks_count":393,"subscribers_count":63,"default_branch":"master","last_synced_at":"2025-03-22T16:02:12.953Z","etag":null,"topics":["animation","custom-icon","heart","icons","twiiter"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jd-alexander.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2015-12-23T17:49:46.000Z","updated_at":"2025-03-16T17:16:35.000Z","dependencies_parsed_at":"2024-10-31T06:32:01.292Z","dependency_job_id":"02306242-e68f-4075-aac2-24ca25667906","html_url":"https://github.com/jd-alexander/LikeButton","commit_stats":null,"previous_names":[],"tags_count":14,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jd-alexander%2FLikeButton","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jd-alexander%2FLikeButton/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jd-alexander%2FLikeButton/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jd-alexander%2FLikeButton/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jd-alexander","download_url":"https://codeload.github.com/jd-alexander/LikeButton/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246012632,"owners_count":20709484,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["animation","custom-icon","heart","icons","twiiter"],"created_at":"2024-07-31T19:01:07.007Z","updated_at":"2025-03-28T10:32:23.553Z","avatar_url":"https://github.com/jd-alexander.png","language":"Java","funding_links":[],"categories":["Java","点赞按钮"],"sub_categories":[],"readme":"# Like Button \n\n[ ![JitPack](https://img.shields.io/github/release/jd-alexander/likebutton.svg?label=jitpack) ](https://jitpack.io/#jd-alexander/likebutton)\n[![Build Status](https://travis-ci.org/jd-alexander/LikeButton.svg)](https://travis-ci.org/jd-alexander/LikeButton)\n[![License](https://img.shields.io/badge/license-Apache%202-4EB1BA.svg?style=flat-square)](https://www.apache.org/licenses/LICENSE-2.0.html)\n[![Android Arsenal](https://img.shields.io/badge/Android%20Arsenal-LikeButton-green.svg?style=true)](https://android-arsenal.com/details/1/3038)\n\n\nLike Button is a library that allows you to create a button with animation effects similar to [Twitter's heart](https://dribbble.com/shots/2416983-Twitter-Heart-Animation) when you like something.\n\n![Icon animations](http://i.giphy.com/3o8dp4uq3K4vvR1MJO.gif \"Icon animations\")\n\n---\n\n# Table of Contents\n\n1. [Gradle Dependency](https://github.com/jd-alexander/LikeButton#gradle-dependency)\n   1. [Repository](https://github.com/jd-alexander/LikeButton#repository)\n   2. [Dependency](https://github.com/jd-alexander/LikeButton#dependency)\n2. [Basic Usage](https://github.com/jd-alexander/LikeButton#basic-usage)\n   1. [Like Button XML](https://github.com/jd-alexander/LikeButton#like-button-xml)\n   2. [Attributes](https://github.com/jd-alexander/LikeButton#attributes)\n3. [Button State](https://github.com/jd-alexander/LikeButton#button-state)\n4. [Like Event Listener](https://github.com/jd-alexander/LikeButton#like-event-listener)\n5. [Icon Types](https://github.com/jd-alexander/LikeButton#icon-types)\n6. [Icon Size](https://github.com/jd-alexander/LikeButton#icon-size)\n7. [Custom Icons](https://github.com/jd-alexander/LikeButton#custom-icons)\n8. [Circle Color Config](https://github.com/jd-alexander/LikeButton#circle-color-config)\n9. [Dots Color Config](https://github.com/jd-alexander/LikeButton#dots-color-config)\n10. [Animation Size](https://github.com/jd-alexander/LikeButton#animation-size)\n11. [Inspiration](https://github.com/jd-alexander/LikeButton#inspiration)\n12. [Contribution](https://github.com/jd-alexander/LikeButton#contribution)\n13. [License](https://github.com/jd-alexander/LikeButton#license)\n\n   \n---\n\n# Gradle Dependency\n\n\n#### Repository\n\nAdd this in your root `build.gradle` file (**not** your module `build.gradle` file):\n\n```gradle\nallprojects {\n\trepositories {\n\t\t...\n\t\tmaven { url \"https://jitpack.io\" }\n\t}\n}\n```\n\n#### Dependency\n\nAdd this to your module's `build.gradle` file:\n\n```gradle\ndependencies {\n\t...\n\tcompile 'com.github.jd-alexander:LikeButton:0.2.3'\n\t}\n}\n```\n\n---\n\n# Basic Usage\n\n#### Like Button XML\n\nTo use this like button in your layout simply copy and paste the xml below. This provides the default heart button. \n\n```xml\n\u003ccom.like.LikeButton\n            app:icon_type=\"heart\"\n            app:icon_size=\"25dp\"\n            android:id=\"@+id/star_button\"\n            android:layout_width=\"wrap_content\"\n            android:layout_height=\"wrap_content\"/\u003e\n```\n\n#### Attributes\n\nThere 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.\n\n```xml\n\u003ccom.like.LikeButton\napp:icon_type=\"Star\"\napp:circle_start_color=\"@color/colorPrimary\"\napp:like_drawable=\"@drawable/thumb_on\"\napp:unlike_drawable=\"@drawable/thumb_off\"\napp:dots_primary_color=\"@color/colorAccent\"\napp:dots_secondary_color=\"@color/colorPrimary\"\napp:circle_end_color=\"@color/colorAccent\"\napp:icon_size=\"25dp\"\napp:liked=\"true\"\napp:anim_scale_factor=\"2\"\napp:is_enabled=\"false\"\n/\u003e\n\n```\n---\n\n# Button State\n\nTo 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.\n\n#### XML\n\n```\napp:liked=\"true\"\n```\n\n#### Java\n\n\n```java\n\nlikeButton.setLiked(true);\n```\n\nYou 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.\n\n#### XML\n\n```\napp:is_enabled=\"false\"\n```\n\n#### Java\n\n\n```java\n\nlikeButton.setEnabled(false);\n```\n\n\n\n---\n\n# Like Event Listener\n\nTo listen to events from your like button, simply implement the listener that's triggered once the button is tapped.\n\n```java\n\nlikeButton.setOnLikeListener(new OnLikeListener() {\n            @Override\n            public void liked(LikeButton likeButton) {\n\n            }\n\n            @Override\n            public void unLiked(LikeButton likeButton) {\n\n            }\n        });\n\n```\n\n---\n\n# Icon Types\n\nThe libary is bundled with three icons that you can use. A heart,thumb and a star. \n\n#### XML\n\nTo set the respective icon via xml simply use the word in the icon type attribute.\n\n```\napp:icon_type=\"heart\"\n```\n\n#### Java\n\nIf you would like to set the icon via Java then simply call the set icon method on the button. \n\n```java\n\nlikeButton.setIcon(IconType.Star);\n```\n---\n\n# Icon Size\n\n#### XML\n\nTo set the icon size via xml simply use this attribute\n\n```xml\napp:icon_size=\"20dp\"\n```\n\n#### Java\n\nIf you are doing it programmatically you can set it with either the method for pixels or dp. \n\n```java\nlikeButton.setIconSizePx(40);\nlikeButton.setIconSizeDp(20);\n```\nNote, 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.\n\n---\n\n# Custom Icons\n\n#### XML\n\nIn 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.\n\n```\napp:like_drawable=\"@drawable/thumb_on\"\napp:unlike_drawable=\"@drawable/thumb_off\"\n```\n\n#### Java\n\n```java\nlikeButton.setLikeDrawable(heart_on);\nlikeButton.setUnlikeDrawable(heart_off);\n\nlikeButton.setUnlikeDrawableRes(R.drawable.heart_off);\nlikeButton.setLikeDrawableRes(R.drawable.heart_on);\n```\n---\n\n# Circle Color Config\n\nIf 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.\n\n#### XML\n\n```\napp:circle_start_color=\"@color/colorPrimary\"\napp:circle_end_color=\"@color/colorAccent\"\n```\n\n#### Java\n\n```java\nlikeButton.setCircleEndColorRes(R.color.colorAccent);\nlikeButton.setCircleEndColorRes(R.color.colorPrimary);\n```\n---\n\n# Dots Color Config\n\nThe dots that represent the outer animation can be coloured also.\n\n#### XML\n\n```\napp:dots_primary_color=\"@color/colorAccent\"\napp:dots_secondary_color=\"@color/colorPrimary\"\n```\n\n#### Java\n\n```\nlikeButton.setExplodingDotColorsRes(R.color.colorPrimary,R.color.colorAccent);\n```\n---\n\n\n# Animation Size\n\nTo 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\n\n#### XML\n\n```\napp:anim_scale_factor=\"2.5\"\n\n```\n\n#### Java\n\n```\nlikeButton.setAnimationScaleFactor(2);\n```\n---\n\n\n# Inspiration\n\nThis library was made by possible based on code and design inspiration from these sources:\n\nhttps://github.com/frogermcs/LikeAnimation\n\nhttps://github.com/lightsmeki/android_twitter_heart_animation_button\n\nhttps://dribbble.com/shots/2416983-Twitter-Heart-Animation\n\n\n\n# Contribution\n\n\nPlease fork repository and contribute using pull requests.\n\nAny 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.\n\n\n# License\n\n    Copyright 2016 Joel Dean\n\n    Licensed under the Apache License, Version 2.0 (the \"License\");\n    you may not use this file except in compliance with the License.\n    You may obtain a copy of the License at\n\n       http://www.apache.org/licenses/LICENSE-2.0\n\n    Unless required by applicable law or agreed to in writing, software\n    distributed under the License is distributed on an \"AS IS\" BASIS,\n    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n    See the License for the specific language governing permissions and\n    limitations under the License.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjd-alexander%2FLikeButton","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjd-alexander%2FLikeButton","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjd-alexander%2FLikeButton/lists"}