{"id":15028123,"url":"https://github.com/varunest/sparkbutton","last_synced_at":"2025-05-16T09:04:45.221Z","repository":{"id":41867664,"uuid":"62922926","full_name":"varunest/SparkButton","owner":"varunest","description":"Android library to create buttons with Twitter's heart like animation.","archived":false,"fork":false,"pushed_at":"2021-11-19T06:27:21.000Z","size":1242,"stargazers_count":1269,"open_issues_count":4,"forks_count":151,"subscribers_count":28,"default_branch":"master","last_synced_at":"2025-05-16T09:04:38.759Z","etag":null,"topics":["android","animation","enhancement","java","library","twitter-heart-animation","ui"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/varunest.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-07-08T23:28:37.000Z","updated_at":"2025-03-24T03:07:13.000Z","dependencies_parsed_at":"2022-07-25T22:32:58.576Z","dependency_job_id":null,"html_url":"https://github.com/varunest/SparkButton","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/varunest%2FSparkButton","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/varunest%2FSparkButton/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/varunest%2FSparkButton/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/varunest%2FSparkButton/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/varunest","download_url":"https://codeload.github.com/varunest/SparkButton/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254501557,"owners_count":22081528,"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":["android","animation","enhancement","java","library","twitter-heart-animation","ui"],"created_at":"2024-09-24T20:07:39.765Z","updated_at":"2025-05-16T09:04:40.210Z","avatar_url":"https://github.com/varunest.png","language":"Java","readme":"\u003c!--\n  Title: Spark Button\n  Description: Highly customizable and lightweight library that allows you to create a button with animation effect similar to Twitter's heart animation.\n  Author: varunest\n  --\u003e\n[![platform](https://img.shields.io/badge/platform-Android-yellow.svg)](https://www.android.com)\n[![API](https://img.shields.io/badge/API-14%2B-brightgreen.svg?style=flat)](https://android-arsenal.com/api?level=14)\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[![](https://jitpack.io/v/varunest/sparkbutton.svg)](https://jitpack.io/#varunest/sparkbutton)\n[![Android Arsenal](https://img.shields.io/badge/Android%20Arsenal-SparkButton-red.svg?style=flat)](http://android-arsenal.com/details/1/3876)\n[![Build Status](https://travis-ci.org/varunest/SparkButton.svg?branch=master)](https://travis-ci.org/varunest/SparkButton)\n\n# SparkButton\nHighly customizable and lightweight library that allows you to create a button with animation effect similar to Twitter's heart animation.\n\nLibrary supports OS on API 14 and above.\n\n![Showcase Video](art/showcase.gif)\n\nGrab the above demo app from here :\n\n[![Get it on Google Play](https://play.google.com/intl/en_us/badges/images/badge_new.png)](https://play.google.com/store/apps/details?id=com.varunest.sample.sparkbutton)\n\n## Dependency\n\nAdd it in your root build.gradle at the end of repositories:\n\n```groovy\nallprojects {\n\trepositories {\n\t\t...\n\t\tmaven { url \"https://jitpack.io\" }\n\t}\n}\n```\t\nand then add dependency\n\n```groovy\ndependencies {\n\tcompile 'com.github.varunest:sparkbutton:1.0.6'\n}\n```\n\n## Usage\n\n### XML\n\n```xml\n\u003ccom.varunest.sparkbutton.SparkButton\n            android:id=\"@+id/spark_button\"\n            android:layout_width=\"40dp\"\n            android:layout_height=\"40dp\"\n            app:sparkbutton_activeImage=\"@drawable/active_image\"\n            app:sparkbutton_inActiveImage=\"@drawable/inactive_image\"\n            app:sparkbutton_iconSize=\"40dp\"\n            app:sparkbutton_primaryColor=\"@color/primary_color\"\n            app:sparkbutton_secondaryColor=\"@color/secondary_color\" /\u003e\n```\n\n### Java\n\n```java\nSparkButton button  = new SparkButtonBuilder(context)\n                .setActiveImage(R.drawable.active_image)\n                .setInActiveImage(R.drawable.inactive_image)\n                .setDisabledImage(R.drawable.disabled_image)\n                .setImageSizePx(getResources().getDimensionPixelOffset(R.dimen.button_size))\n                .setPrimaryColor(ContextCompat.getColor(context, R.color.primary_color))\n                .setSecondaryColor(ContextCompat.getColor(context, R.color.secondary_color))\n                .build();\n```\n\n### Attributes\n\n```xml\n\u003cattr name=\"sparkbutton_iconSize\" format=\"dimension|reference\" /\u003e\n\u003cattr name=\"sparkbutton_activeImage\" format=\"reference\" /\u003e\n\u003cattr name=\"sparkbutton_disabledImage\" format=\"reference\" /\u003e\n\u003cattr name=\"sparkbutton_primaryColor\" format=\"reference\" /\u003e\n\u003cattr name=\"sparkbutton_secondaryColor\" format=\"reference\" /\u003e\n\u003cattr name=\"sparkbutton_pressOnTouch\" format=\"boolean\" /\u003e\n\u003cattr name=\"sparkbutton_animationSpeed\" format=\"float\" /\u003e\n```\n\n## Documentation\nTo use SparkButton simply include XML script or build it using SparkButtonBuilder as stated above.\n\nVarious attributes that you can control are following: \n\n### Button Image and Colors\nYou 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.\n\nSparkButton takes two colors primary and secondary. (It is recommended that primary color is lighter than secondary for better results).\n\n#### XML\n```xml\napp:sparkbutton_activeImage=\"@drawable/active_image\"\napp:sparkbutton_inActiveImage=\"@drawable/inactive_image\"\napp:sparkbutton_primaryColor=\"@color/primaryColor\"\napp:sparkbutton_secondaryColor=\"@color/secondaryColor\"\n```\n#### Java\n```java\nSparkButton button = new SparkButtonBuilder(context)\n\t\t\t\t\t\t.setActiveImage(R.drawable.active_image)\n\t\t\t\t\t\t.setInActiveImage(R.drawable.inactive_image)\n\t\t\t\t\t\t.setPrimaryColor(ContextCompat.getColor(context, R.color.primary_color))\n\t\t\t\t\t\t.setSecondaryColor(ContextCompat.getColor(context, R.color.secondary_color))\n\t\t\t\t\t\t.build();\n```\n\n### Animation Speed\nYou can specify the fraction by which the animation speed should increase/decrease.\n\n#### XML\n```xml\napp:sparkbutton_animationSpeed=\"1.5\"\n```\n\n#### Java\n```java\nsparkbutton.setAnimationSpeed(1.5f);\n```\n\n### Button State\nIf you are using the SparkButton as a switch, you can \ncheck/uncheck the button\n\n```java\nsparkButton.setChecked(true);\n```\n\n### Event Listener\n\nSimply call setEventListener to listen click events. \n\n```java\nsparkButton.setEventListener(new SparkEventListener(){\n\t\t@Override\n\t\tvoid onEvent(ImageView button, boolean buttonState) {\n\t\t\tif (buttonState) {\n\t\t\t\t// Button is active\n\t\t\t} else {\n\t\t\t\t// Button is inactive\n\t\t\t}\n\t\t}\n});\n```\n\n### Play Animation\nIf you want to play animation regardless of click event execute following function:\n\n```java\nsparkButton.playAnimation();\n```\n\n## Advanced\n* \tThere can be a situation when you don't want the button to \tscale download when pressed or consume touch. You can \tavoid this by calling the following function :\n\n\t```java\n\tsparkButton.pressOnTouch(false);\n\t```\n\n* \tIf you are using SparkButton between layout hierarchy, it \tcan result in **animation getting cropped**. To avoid this \tcropping of the animation, set `clipChildren` and \t`clipToPadding` XML attribute of all the parent views \n\tto `false`.\n\n* \tYou can view examples of few custom buttons in the [sample \tapp](app).\n\n## Inspiration\nSparkButton was inspired by : [https://github.com/frogermcs/LikeAnimation](https://github.com/frogermcs/LikeAnimation)\n\n## Contribution\nAny contributions, large or small, features, bug fixes are welcomed and appreciated. Use pull requests, they will be thoroughly reviewed and discussed.\n\n## Link Backs\nIf 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 mailvarunest@gmail.com.\n\n## License\nLibrary falls under [Apache 2.0] (LICENSE.md)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvarunest%2Fsparkbutton","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvarunest%2Fsparkbutton","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvarunest%2Fsparkbutton/lists"}