Skip to content

stramChen/SwitchButton

Repository files navigation

效果

SwitchButton

使用方法

1.style.xml中引入自定义标签
 <declare-styleable name="SwitchButton">
 <attr name="sb_shadow_radius" format="reference|dimension" />
 <attr name="sb_shadow_offset" format="reference|dimension" />
 <attr name="sb_shadow_color" format="reference|color" />
 <attr name="sb_uncheck_color" format="reference|color" />
 <attr name="sb_checked_color" format="reference|color" />
 <attr name="sb_border_width" format="reference|dimension" />
 <attr name="sb_checkline_color" format="reference|color" />
 <attr name="sb_checkline_width" format="reference|dimension" />
 <attr name="sb_uncheckcircle_color" format="reference|color" />
 <attr name="sb_uncheckcircle_width" format="reference|dimension" />
 <attr name="sb_uncheckcircle_radius" format="reference|dimension" />
 <attr name="sb_checked" format="reference|boolean" />
 <attr name="sb_shadow_effect" format="reference|boolean" />
 <attr name="sb_effect_duration" format="reference|integer" />
 <attr name="sb_button_color" format="reference|color" />
 <attr name="sb_show_indicator" format="reference|boolean" />
 <attr name="sb_background" format="reference|color" />
 <attr name="sb_enable_effect" format="reference|boolean" />
 </declare-styleable>
2.引入自定义View布局
<per.stramchen.switchbuttondemo.SwitchButton
	android:id="@+id/btn_voice_switch"
	android:layout_width="wrap_content"
	android:layout_height="wrap_content"
	android:layout_weight="1"
	app:sb_background="#E8E9EB"
	app:sb_checked_color="#65C065"
	app:sb_show_indicator="false" />
3.设置监听
        switchButton.setOnCheckedChangeListener(
        new SwitchButton.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(SwitchButton view, final boolean isChecked) {

            }
        });

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages