android-state-button
android-state-button copied to clipboard
多状态按钮
android-state-button
About
android-state-button is a custom view for mutil state button.
Demo
![](https://github.com/mazouri/android-state-button/raw/master/screenshot/state_button_demo.gif)
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 | 正常状态的文字颜色 |
disabledBackground | disabled状态的背景 |
---|---|
disabledText | disabled状态的文字 |
disabledIcon | disabled状态的图标 |
disabledTextColor | disabled状态的文字颜色 |
selectedBackground | 选择状态的背景 |
---|---|
selectedText | 选择状态的文字 |
selectedIcon | 选择状态的图标 |
selectedTextColor | 选择状态的文字颜色 |
drawablePadding | 图标与文字间距 |
---|---|
iconTopMargin | 图标上方间距 |
iconWidth | 图标宽度 |
iconHeight | 图标高度 |
state | StateButton默认状态 |
You can also fork this project to update your own states