This is a UI lib for Android. Effects like shining.

Overview

ShineButton

license platform Build Status Android Arsenal API

This is a UI lib for Android. Effects like shining.

preview

Usage

 shineButton = (ShineButton) findViewById(R.id.shine_button);
 shineButton.init(activity);

or

 ShineButton shineButtonJava = new ShineButton(this);
 shineButtonJava.setBtnColor(Color.GRAY);
 shineButtonJava.setBtnFillColor(Color.RED);
 shineButtonJava.setShapeResource(R.raw.heart);
 shineButtonJava.setAllowRandomColor(true);
 LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(100, 100);
 shineButtonJava.setLayoutParams(layoutParams);
 if (linearLayout != null) {
     linearLayout.addView(shineButtonJava);
 }

Simple Usage

Icon shape is made from png mask. Please see raw files.

app:siShape

Default button color.

app:btn_color

Fill button color.

app:btn_fill_color

If this property is true,the effects will become random color shine.

app:allow_random_color

preview

 <com.sackcentury.shinebuttonlib.ShineButton
                android:layout_width="50dp"
                android:layout_height="50dp"
                android:layout_centerInParent="true"
                android:src="@android:color/darker_gray"
                android:id="@+id/po_image2"
                app:btn_color="@android:color/darker_gray"
                app:btn_fill_color="@android:color/holo_green_dark"
                app:allow_random_color="false"
                app:siShape="@raw/smile"/>

Complex Usage

Property Java method Description
siShape void setShapeResource(int) Set raw resource (png)
btn_color void setBtnColor(int) Set origin color
btn_fill_color void setBtnFillColor(int) Set fill color after click
allow_random_color void setAllowRandomColor(boolean) Allow shine color random
shine_animation_duration void setAnimDuration(int) Set shine anim duration
big_shine_color void setBigShineColor(int) Set big shine color
click_animation_duration void setClickAnimDuration(int) Set click anim duration
enable_flashing void enableFlashing(boolean) Enable effect like flash
shine_count void setShineCount(int) Set shine count around button
shine_distance_multiple void setShineDistanceMultiple(float) Set multiple of distance to button
shine_turn_angle void setShineTurnAngle(float) Set turn angle of shine
shine_size void setShineSize(int) Set size of shine by pixel
small_shine_color void setSmallShineColor(int) Set small shine color
small_shine_offset_angle void setSmallShineOffAngle(float) Set angle offset of small shine to big shine
app:shine_turn_angle="20"
app:shine_count="15"
app:allow_random_color="true"
app:enable_flashing="true"

preview

<com.sackcentury.shinebuttonlib.ShineButton
                android:layout_width="50dp"
                android:layout_height="50dp"
                android:layout_centerInParent="true"
                android:src="@android:color/darker_gray"
                android:id="@+id/po_image1"
                app:btn_color="@android:color/darker_gray"
                app:btn_fill_color="#FF6666"
                app:allow_random_color="false"
                app:enable_flashing="false"
                app:big_shine_color="#FF6666"
                app:click_animation_duration="200"
                app:shine_animation_duration="1500"
                app:shine_turn_angle="10"
                app:small_shine_offset_angle="20"
                app:shine_distance_multiple="1.5f"
                app:small_shine_color="#CC9999"
                app:shine_count="8"
                app:siShape="@raw/like"/>

Support Dialog

When use button on a Dialog

shineButton.setFixDialog(dialog);

Easy to support.

Requirements

  • Android 4.0+

Code Reference

android-shape-imageview EasingInterpolator

Maven

<dependency>
  <groupId>com.sackcentury</groupId>
  <artifactId>shinebutton</artifactId>
  <version>1.0.0</version>
  <type>aar</type>
</dependency>

Gradle

buildscript {
    repositories {
        mavenCentral()
    }
}
dependencies {
    compile 'com.sackcentury:shinebutton:1.0.0'
}

Further

1, SVG support;
2, Font support;
3, Image support...

Credits

iOS lib fave-button Android implement. FaveButton was inspired by Twitter’s Like Heart Animation;

Third Party Bindings

React Native

You may now use this library with React Native via the module here

License

The MIT License (MIT)

Copyright (c) 2016 Chad Song 

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Comments
  • Animation at wrong location when using a Dialog

    Animation at wrong location when using a Dialog

    I gave the dialog a specific size approximately in the center of the screen and the shine animation happens on the top left corner of it and the scale+change image color happens normally where the button is located.

    I think the fix would be inside showAnim. rootView.addView(shineView, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));

    bug 
    opened by asafvaron90 11
  • Can't use ShineButton in a CardView

    Can't use ShineButton in a CardView

    I want to use ShineButton into my cardview but when i introduce it into the cardview it doesn't show anything. Here is my xml code

    <android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/tools" android:id="@+id/card_game" android:layout_width="match_parent" xmlns:cardview="http://schemas.android.com/apk/res-auto" android:layout_height="wrap_content" cardview:cardUseCompatPadding="true" cardview:cardCornerRadius="2dp" cardview:cardElevation="2dp">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical">
    
        <ImageView
            android:id="@+id/image_view"
            android:layout_width="375dp"
            android:layout_height="160dp"
            android:layout_gravity="center_horizontal"
            android:scaleType="centerCrop" />
    
        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="51dp"
            android:orientation="vertical">
    
            <TextView
                android:id="@+id/title_name"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="pavel"
                android:layout_margin="8dp"
                android:maxLines="3" />
    
            <com.sackcentury.shinebuttonlib.ShineButton
                android:layout_width="50dp"
                android:layout_height="50dp"
                android:layout_centerInParent="true"
                android:id="@+id/po_image0"
                app:btn_color="#FF6666"
                app:btn_fill_color="#999933"
                app:siShape="@raw/heart"
                android:layout_gravity="right"
                android:layout_centerVertical="true"
                android:layout_alignParentRight="true"
                android:layout_alignParentEnd="true"/>
    
            <TextView
                android:id="@+id/movie_name"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="robin"
                android:layout_margin="8dp"
                android:layout_alignParentBottom="true"
                />
    
        </RelativeLayout>
    
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal">
    
    
        </LinearLayout>
    
    
    </LinearLayout>
    

    </android.support.v7.widget.CardView>

    question 
    opened by pavelsust 6
  • Problem with RecyclerView

    Problem with RecyclerView

    when i click on one of the shine button and scroll away from that position, on getting back to it, it will deselect itself automatically. How can i fix this, i notice the same thing in the example you provided for the list view

    question 
    opened by moderateepheezy 6
  • [Feature Request] Configure size of shines

    [Feature Request] Configure size of shines

    @ChadCSong Please mark this as a feature request, thank you!

    Shines are sized proportionally to the size of the icon it is being applied to. This means that small icons will have shines that are barely visible and certainly not enough dramatic effect. Is there an option to resize the shines? For example, I have a 24dp icon but I would like the shines to be bigger so they show up better.

    Thank you for all the great work and making this resource available to everyone!

    enhancement 
    opened by searchy2 6
  • Manifest merger failed, spent many hours in it. How to fix this.

    Manifest merger failed, spent many hours in it. How to fix this.

    FAILURE: Build failed with an exception.

    • What went wrong: Execution failed for task ':app:processDebugManifest'.

      Manifest merger failed : Attribute [email protected] value=(false) from AndroidManifest.xml:27:9-35 is also present at AndroidManifest.xml:27:9-35 value=(true). Suggestion: add 'tools:replace="android:allowBackup"' to element at AndroidManifest.xml:20:5-23:76 to override.

    • Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

    question 
    opened by hishamMuneer 4
  • Wrong animation position after fullscreen

    Wrong animation position after fullscreen

    Hi,

    First of all - thanks for such a great lib!

    I have a problem with animation position after entering and exiting activity fullscreen mode.

    In landscape mode my app goes fullscreen hiding all system UI. When I resume to portrait and exit fullscreen shining animations starts in wrong place!

    Please help.

    bug 
    opened by oleynikd 4
  • click quickly will load error button color

    click quickly will load error button color

    such like this. I click quickly.

    The last check callback is false. So the text color is right. But the btn color is error. It look like it the shakeAnimator's problem. Because shakeAnimator onAnimationStart will call setSrcColor(color) . I think set Animation Listener like this.

    shakeAnimator.addListener(new Animator.AnimatorListener() {
        @Override
        public void onAnimationStart(Animator animator) {
            if (isChecked()) {
                setSrcColor(btnFillColor);
            }
        }
    
        @Override
        public void onAnimationEnd(Animator animator) {
            onListenerUpdate(isChecked());
        }
    
        @Override
        public void onAnimationCancel(Animator animator) {
            onListenerUpdate(isChecked());
        }
    
        @Override
        public void onAnimationRepeat(Animator animator) {
    
        }
    });
    

    and do some work in the onCheck callback.

    mPariseImg.setOnCheckStateChangeListener(new ShineButton.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(View view, boolean isCheck) {
            if (!isCheck) {
                mPariseImg.setSrcColor(getResources().getColor(R.color.doctor_push_dis_vote));
            }
        }
    });
    

    It can do well. I think it can add to readme.

    bug 
    opened by chenzj-king 3
  • Improve GRADLE build Performance

    Improve GRADLE build Performance

    Parallel test execution maxParallelForks. Gradle can run multiple test cases in parallel by setting maxParallelForks.

    Disable report generation. We can conditionally disable it by setting reports.html.required = false; reports.junitXml.required = false. If you need to generate reports, add -PcreateReports to the end of Gradle's build command line.

    ===================== If there are any inappropriate modifications in this PR, please give me a reply and I will change them.

    opened by i-Taozi 2
  • App crashes on ShineButton click, NoClassDefFoundError

    App crashes on ShineButton click, NoClassDefFoundError

     java.lang.NoClassDefFoundError: Failed resolution of: Landroid/animation/Animator$AnimatorListener$$CC;
                                                           at com.sackcentury.shinebuttonlib.ShineView$3.onAnimationStart(Unknown Source:0)
                                                           at android.animation.ValueAnimator.notifyStartListeners(ValueAnimator.java:990)
                                                           at android.animation.ValueAnimator.startAnimation(ValueAnimator.java:1239)
                                                           at android.animation.ValueAnimator.start(ValueAnimator.java:1041)
                                                           at android.animation.ValueAnimator.start(ValueAnimator.java:1065)
                                                           at com.sackcentury.shinebuttonlib.ShineAnimator.startAnim(ShineAnimator.java:38)
                                                           at com.sackcentury.shinebuttonlib.ShineView.showAnimation(ShineView.java:201)
                                                           at com.sackcentury.shinebuttonlib.ShineView.onDraw(ShineView.java:232)
                                                           at android.view.View.draw(View.java:18731)
                                                           at android.view.View.updateDisplayListIfDirty(View.java:17681)
                                                           at android.view.View.draw(View.java:18459)
                                                           at android.view.ViewGroup.drawChild(ViewGroup.java:4184)
                                                           at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3970)
                                                           at android.view.View.updateDisplayListIfDirty(View.java:17672)
                                                           at android.view.View.draw(View.java:18459)
                                                           at android.view.ViewGroup.drawChild(ViewGroup.java:4184)
                                                           at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3970)
                                                           at android.view.View.updateDisplayListIfDirty(View.java:17672)
                                                           at android.view.View.draw(View.java:18459)
                                                           at android.view.ViewGroup.drawChild(ViewGroup.java:4184)
                                                           at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3970)
                                                           at android.view.View.updateDisplayListIfDirty(View.java:17672)
                                                           at android.view.View.draw(View.java:18459)
                                                           at android.view.ViewGroup.drawChild(ViewGroup.java:4184)
                                                           at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3970)
                                                           at android.view.View.updateDisplayListIfDirty(View.java:17672)
                                                           at android.view.View.draw(View.java:18459)
                                                           at android.view.ViewGroup.drawChild(ViewGroup.java:4184)
                                                           at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3970)
                                                           at android.view.View.draw(View.java:18734)
                                                           at com.android.internal.policy.DecorView.draw(DecorView.java:763)
                                                           at android.view.View.updateDisplayListIfDirty(View.java:17681)
                                                           at android.view.ThreadedRenderer.updateViewTreeDisplayList(ThreadedRenderer.java:636)
                                                           at android.view.ThreadedRenderer.updateRootDisplayList(ThreadedRenderer.java:642)
                                                           at android.view.ThreadedRenderer.draw(ThreadedRenderer.java:750)
                                                           at android.view.ViewRootImpl.draw(ViewRootImpl.java:2975)
                                                           at android.view.ViewRootImpl.performDraw(ViewRootImpl.java:2789)
                                                           at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2356)
                                                           at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1385)
                                                           at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6729)
                                                           at android.view.Choreographer$CallbackRecord.run(Choreographer.java:886)
                                                           at android.view.Choreographer.doCallbacks(Choreographer.java:698)
                                                           at android.view.Choreographer.doFrame(Choreographer.java:633)
                                                           at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:872)
                                                           at android.os.Handler.handleCallback(Handler.java:769)
                                                           at android.os.Handler.dispatchMessage(Handler.java:98)
                                                           at android.os.Looper.loop(Looper.java:164)
                                                           at android.app.ActivityThread.main(ActivityThread.java:6535)
                                                           at java.lang.reflect.Method.invoke(Native Method)
                                                           at ```
    com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
                                                           at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)
    E/AndroidRuntime: Caused by: java.lang.ClassNotFoundException: Didn't find class "android.animation.Animator$AnimatorListener$$CC" on path: DexPathList[[zip file "/data/app/...-YaVovrqzuZuLptV57qTLUQ==/base.apk", zip file "/data/app/...-YaVovrqzuZuLptV57qTLUQ==/split_lib_dependencies_apk.apk", zip file "/data/app/...-YaVovrqzuZuLptV57qTLUQ==/split_lib_slice_0_apk.apk", zip file "/data/app/...-YaVovrqzuZuLptV57qTLUQ==/split_lib_slice_1_apk.apk", zip file "/data/app/...-YaVovrqzuZuLptV57qTLUQ==/split_lib_slice_2_apk.apk", zip file "/data/app/...-YaVovrqzuZuLptV57qTLUQ==/split_lib_slice_3_apk.apk", zip file "/data/app/...-YaVovrqzuZuLptV57qTLUQ==/split_lib_slice_4_apk.apk", zip file "/data/app/...-YaVovrqzuZuLptV57qTLUQ==/split_lib_slice_5_apk.apk", zip file "/data/app/...-YaVovrqzuZuLptV57qTLUQ==/split_lib_slice_6_apk.apk", zip file "/data/app/...-YaVovrqzuZuLptV57qTLUQ==/split_lib_slice_7_apk.apk", zip file "/data/app/...-YaVovrqzuZuLptV57qTLUQ==/split_lib_slice_8_apk.apk", zip file "/data/app/...-YaVovrqzuZuLptV57qTLUQ==/split_lib_slice_9_apk.apk"],nativeLibraryDirectories=[/data/app...-YaVovrqzuZuLptV57qTLUQ==/lib/x86, /system/lib, /system/vendor/lib]]
                                                           at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:93)
                                                           at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
                                                           at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
                                                           	... 51 more
    

    This crash happens with all the latest updates, i. e. Android Studio 3.0 Canary 4, Java 8, Android O etc. It might be due to Java 8 because it is the only thing I haven't tested, but can you please tell me how to fix this bug / fix it? Great library btw.

    help wanted question 
    opened by creativecreatorormaybenot 2
  • Doesn't work when no listener are defined

    Doesn't work when no listener are defined

    Hi,

    I have tried to use this button but it doesn't work when I just initialize button with :

    shineButton.init(getActivity());

    But when I had a listener like that, it works :

    shineButton.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    Log.d("Click","Click");
                }
            }); 
    

    Ps : I have tried in a activity and in a fragment

    bug enhancement 
    opened by BenjaminBihr 2
  • Updated code to androidx

    Updated code to androidx

    Hey,

    Thanks for such a great library.

    I had just updated your code to androidx which is going to be mandatory for all android apps by the end of 2019 according to the notification by google.

    opened by Faiyyaz 1
  • not removing shining effect after click to shine

    not removing shining effect after click to shine

    After click on shine button to shine after shine effect done shine effect will not go away and in recyclerview it happens same and when click multi shine items it effect app performance . And as i scroll shine scroll with it.(see in picture)

    Screenshot_20200820-113304

    opened by erfanxvv 0
  • ShineView didn't remove after shine finished.

    ShineView didn't remove after shine finished.

    Following change to fix this:

    In ShineView lin 128 shineButton.removeView(ShineView.this);

    replace with: ((ViewGroup) ShineView.this.getParent()).removeView(ShineView.this);

    Or modify ShineButton.removeView function.

    opened by mrchihlungchen 1
Releases(v0.2.0)
Owner
Chad Song
Be Hungry.
Chad Song
Base on android-process-button this is the advanced version of the android-process-button.

Rock Button release log Base on android-process-button this is the advanced version of the android-process-button ##Main Features ActionProcessButton

MDCCLXXVI KPT 119 Nov 25, 2022
Android Circular Progress Button

?? Before using this library, read information below ?? This library is not more supported. If you want to add new feature or fix a bug, grab source

Dmytro Danylyk 5.6k Nov 22, 2022
Android Buttons With Built-in Progress Meters.

Description Android Buttons With Built-in Progress Meters. Wiki Home Screenshots User Guide Integration The lib is available on Maven Central, you can

Dmytro Danylyk 3k Nov 20, 2022
Circle button widget for Android

DEPRECATED This library is deprecated and no new development is taking place. Consider using a FAB(Floating action button) instead. E.g. the Android D

Markus Hintersteiner 1.5k Nov 26, 2022
FButton - a flat button library for Android

FButton FButton is a custom Button of Android with "Flat UI" concept. FButton's design get inspiration from designmono. This library is very small and

Le Van Hoang 1.4k Nov 17, 2022
Android button which moves in eight direction.

Moving Button Android button which moves in eight direction. Preview Sample Demo You can download demo movie file here : demo.mov It's also on Youtube

Leonardo Taehwan Kim 131 Nov 16, 2022
Button for android with animations for transition and error states.

Transition Button Android Preview Expand animation: Shake animation: Installation Gradle dependencies { implementation 'com.royrodriguez:transitionbu

Roy Rodriguez 133 Dec 1, 2022
AwesomeSwitch is a replacement for the standard Switch(View) android offers, and it offers much more customization than the standard switch component.

AwesomeSwitch AwesomeSwitch is a replacement for the standard Switch(View) android offers, and it offers much more customization than the standard swi

Anoop S S 29 Jun 2, 2022
[] Android floating action button

DEPRECATED Use the FloatingActionButton from the support library instead. FloatingActionButton Description Android floating action button which reacts

Oleksandr Melnykov 4k Nov 19, 2022
Floating Action Button for Android based on Material Design specification

FloatingActionButton Yet another library for drawing Material Design promoted actions. Features Support for normal 56dp and mini 40dp buttons. Customi

Zendesk 6.4k Nov 21, 2022
Bootstrap style widgets for Android, with Glyph Icons

Android-Bootstrap Android Bootstrap is an Android library which provides custom views styled according to the Twitter Bootstrap Specification. This al

Bearded Hen 7.3k Nov 18, 2022
ToggleButton Widget For Android Dev

ToggleButton ToggleButton Widget For Android Developers @Deprecated !!!项目已经停止维护,新项目移至https://github.com/zcweng/SwitchButton !!! How To Use xml

suke 2.1k Nov 23, 2022
Icons, Borders, Radius ... for Android buttons

⚠️ This library was made years ago when it wasn't that easy to customize Android buttons like today. I highly recommend you to use Material Design but

Mehdi Sakout 1.8k Nov 13, 2022
Android Floating ActionButton with a progress indicator ring

FabProgress Android Circular floating action button with intergrated progress indicator ring As per material design docs Demo: Demo apk HOW TO ADD TO

Kurt Mbanje 779 Nov 28, 2022
👏 The Medium's Clapping Effect developed in Android

?? MediumClap-Android Built with ❤︎ by Wajahat Karim and contributors A Custom Floating Action Button (FAB) library like clapping effect on Medium ??

Wajahat Karim 494 Nov 10, 2022
[] An Android library for an expandable button menu

ExpandableButtonMenu ExpandableButtonMenu is an Android library which implements an expandable button that can be used as a substitute of a fixed size

Lemon Labs 325 Nov 14, 2022
SwitchButton 是 Android 上的一个开关按钮控件 【Deprecated】【Stop maintenance】

SwitchButton 【Deprecated】【Stop maintenance】停止维护了,推荐使用:https://github.com/zcweng/SwitchButton SwitchButton 是 Android 上的一个开关按钮控件 示例 APP 扫描二维码或点我下载 特性 支持

Nameless 334 Nov 15, 2022
A lightweight iOS switch view style for Android

iOS-SwitchView A lightweight iOS switch view style for Android Usage Add SwitchView into xml layout <vn.luongvo.widget.iosswitchview.SwitchView an

Luong Vo (Lucas) 72 Nov 5, 2022
SegmentedController is an Android UI library for using customizable RadioGroup with RadioButtons.

SegmentedController is an Android UI library for using customizable RadioGroup with RadioButtons.

null 2 Jan 1, 2022