Android 发现一个炫酷按钮库(ShineButton)

ShineButton是一款适用于Android的UI库,提供炫彩发光效果的按钮组件。支持自定义颜色、形状资源、动画时长等,通过XML属性或Java方法灵活配置。兼容Android 4.0及以上版本。

原文地址:https://blog.youkuaiyun.com/Gpwner/article/details/53998171

GitHub地址:https://github.com/ChadCSong/ShineButton

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

PropertyJava methodDescription
siShapevoid setShapeResource(int)Set raw resource (png)
btn_colorvoid setBtnColor(int)Set origin color
btn_fill_colorvoid setBtnFillColor(int)Set fill color after click
allow_random_colorvoid setAllowRandomColor(boolean)Allow shine color random
shine_animation_durationvoid setAnimDuration(int)Set shine anim duration
big_shine_colorvoid setBigShineColor(int)Set big shine color
click_animation_durationvoid setClickAnimDuration(int)Set click anim duration
enable_flashingvoid enableFlashing(boolean)Enable effect like flash
shine_countvoid setShineCount(int)Set shine count around button
shine_distance_multiplevoid setShineDistanceMultiple(float)Set multiple of distance to button
shine_turn_anglevoid setShineTurnAngle(float)Set turn angle of shine
shine_sizevoid setShineSize(int)Set size of shine by pixel
small_shine_colorvoid setSmallShineColor(int)Set small shine color
small_shine_offset_anglevoid 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"/>

Requirements

  • Android 4.0+

Code Reference

android-shape-imageview EasingInterpolator

Maven

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

Gradle

buildscript {
    repositories {
        mavenCentral()
    }
}
dependencies {
    compile 'com.sackcentury:shinebutton:0.2.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


5.ShineButton常用的方法说明 
这里写图片描述

 

评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值