项目作者: ChadCSong

项目描述 :
This is a UI lib for Android. Effects like shining.
高级语言: Java
项目地址: git://github.com/ChadCSong/ShineButton.git
创建时间: 2016-07-05T06:32:26Z
项目社区:https://github.com/ChadCSong/ShineButton

开源协议:MIT License

下载


ShineButton

license
platform
Build Status
Android Arsenal
API

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

preview

Usage

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

or

  1. ShineButton shineButtonJava = new ShineButton(this);
  2. shineButtonJava.setBtnColor(Color.GRAY);
  3. shineButtonJava.setBtnFillColor(Color.RED);
  4. shineButtonJava.setShapeResource(R.raw.heart);
  5. shineButtonJava.setAllowRandomColor(true);
  6. LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(100, 100);
  7. shineButtonJava.setLayoutParams(layoutParams);
  8. if (linearLayout != null) {
  9. linearLayout.addView(shineButtonJava);
  10. }

Simple Usage

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

  1. app:siShape

Default button color.

  1. app:btn_color

Fill button color.

  1. app:btn_fill_color

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

  1. app:allow_random_color

preview

  1. <com.sackcentury.shinebuttonlib.ShineButton
  2. android:layout_width="50dp"
  3. android:layout_height="50dp"
  4. android:layout_centerInParent="true"
  5. android:src="@android:color/darker_gray"
  6. android:id="@+id/po_image2"
  7. app:btn_color="@android:color/darker_gray"
  8. app:btn_fill_color="@android:color/holo_green_dark"
  9. app:allow_random_color="false"
  10. app:siShape="@raw/smile"></com.sackcentury.shinebuttonlib.ShineButton>

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
  1. app:shine_turn_angle="20"
  2. app:shine_count="15"
  3. app:allow_random_color="true"
  4. app:enable_flashing="true"

preview

  1. <com.sackcentury.shinebuttonlib.ShineButton
  2. android:layout_width="50dp"
  3. android:layout_height="50dp"
  4. android:layout_centerInParent="true"
  5. android:src="@android:color/darker_gray"
  6. android:id="@+id/po_image1"
  7. app:btn_color="@android:color/darker_gray"
  8. app:btn_fill_color="#FF6666"
  9. app:allow_random_color="false"
  10. app:enable_flashing="false"
  11. app:big_shine_color="#FF6666"
  12. app:click_animation_duration="200"
  13. app:shine_animation_duration="1500"
  14. app:shine_turn_angle="10"
  15. app:small_shine_offset_angle="20"
  16. app:shine_distance_multiple="1.5f"
  17. app:small_shine_color="#CC9999"
  18. app:shine_count="8"
  19. app:siShape="@raw/like"></com.sackcentury.shinebuttonlib.ShineButton>

Support Dialog

When use button on a Dialog

  1. shineButton.setFixDialog(dialog);

Easy to support.

Requirements

  • Android 4.0+

Code Reference

android-shape-imageview
EasingInterpolator

Maven

  1. <dependency>
  2. <groupId>com.sackcentury</groupId>
  3. <artifactId>shinebutton</artifactId>
  4. <version>1.0.0</version>
  5. <type>aar</type>
  6. </dependency>

Gradle

  1. buildscript {
  2. repositories {
  3. mavenCentral()
  4. }
  5. }
  6. dependencies {
  7. compile 'com.sackcentury:shinebutton:1.0.0'
  8. }

#

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

  1. The MIT License (MIT)
  2. Copyright (c) 2016 Chad Song
  3. Permission is hereby granted, free of charge, to any person obtaining a copy
  4. of this software and associated documentation files (the "Software"), to deal
  5. in the Software without restriction, including without limitation the rights
  6. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  7. copies of the Software, and to permit persons to whom the Software is
  8. furnished to do so, subject to the following conditions:
  9. The above copyright notice and this permission notice shall be included in all
  10. copies or substantial portions of the Software.
  11. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  12. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  13. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  14. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  15. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  16. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  17. SOFTWARE.