开源库android-state-button 为Android打造的多状态按钮

本文介绍了一个名为 Android StateButton 的自定义视图组件,它适用于实现不同状态的按钮功能。该组件支持三种状态:启用、禁用和选中,并且可以自定义每种状态下的背景、文字、图标及颜色等属性。

android-state-button

欢迎star或者fork

github地址

About

android-state-button is a custom view for mutil state button.

Demo

android-state-button-demo

How to use?

1.Add it in your root build.gradle at the end of repositories:

    allprojects {
        repositories {
            ...
            maven { url 'https://jitpack.io' }
        }
    }

2.Add the dependency

    dependencies {
            compile 'com.github.mazouri:android-state-button:1.0'
    }
        <mazouri.statebutton.StateButton
            android:id="@+id/state_button"
            android:layout_width="90dp"
            android:layout_height="90dp"
            app:enabledBackground="@drawable/state_button_bg_enable"
            app:enabledText="关闭"
            app:enabledIcon="@drawable/ic_lock_open"
            app:enabledTextColor="#ffffff"
            app:disabledBackground="@drawable/state_button_bg_disable"
            app:disabledText="无效"
            app:disabledIcon="@drawable/ic_lock_disable"
            app:disabledTextColor="#33ffffff"
            app:selectedBackground="@drawable/state_button_bg_selected"
            app:selectedText="打开"
            app:selectedIcon="@drawable/ic_lock"
            app:selectedTextColor="#ffffff"
            app:drawablePadding="10dp"
            app:iconTopMargin="18dp"
            app:iconWidth="30dp"
            app:iconHeight="30dp"
            app:state="enabled"/>
enabledBackground正常状态的背景
enabledText正常状态的文字
enabledIcon正常状态的图标
enabledTextColor正常状态的文字颜色
disabledBackgrounddisabled状态的背景
disabledTextdisabled状态的文字
disabledIcondisabled状态的图标
disabledTextColordisabled状态的文字颜色
selectedBackground选择状态的背景
selectedText选择状态的文字
selectedIcon选择状态的图标
selectedTextColor选择状态的文字颜色
drawablePadding图标与文字间距
iconTopMargin图标上方间距
iconWidth图标宽度
iconHeight图标高度
stateStateButton默认状态

欢迎stfork

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值