Skip to content

mazouri/android-state-button

Repository files navigation

android-state-button

About

android-state-button is a custom view for mutil 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默认状态

You can also fork this project to update your own states