ToggleButton
zcweng
2062
Visit GitHub RepoCheckboxes

ToggleButton

ToggleButton Widget For Android Developers

@Deprecated
!!!项目已经停止维护,新项目移至https://github.com/zcweng/SwitchButton !!!

How To Use

        xmlns:toggle="http://schemas.android.com/apk/res-auto"


        <com.zcw.togglebutton.ToggleButton
            android:layout_width="54dp"
            toggle:tbOnColor="#f00"
            toggle:tbOffColor="#ddd"
            toggle:tbSpotColor="#00f"
            toggle:tbOffBorderColor="#000"
            toggle:tbBorderWidth="2dp"
            android:layout_height="30dp" >
        </com.zcw.togglebutton.ToggleButton>
        ToggleButton toggleBtn;
        
        //切换开关
        toggleBtn.toggle();
        //切换无动画
        toggleBtn.toggle(false);
        //开关切换事件
        toggleBtn.setOnToggleChanged(new OnToggleChanged(){
                @Override
                public void onToggle(boolean on) {
                }
        });
        
        toggleBtn.setToggleOn();
        toggleBtn.setToggleOff();
        //无动画切换
        toggleBtn.setToggleOn(false);
        toggleBtn.setToggleOff(false);
        
        //禁用动画
        toggleBtn.setAnimate(false);

Default Size:width=50dp,height=30dp.

引用方式

2016/8/3 17:04:53 
compile 'com.zcw:togglebutton-library:1.0.0'
Become a better Android Developer
Millions of developers are learning at MindOrks

Online Training Program

Featured Blogs

Our Team

MindOrks is Certainly one of the best online blog to stay on top of all the Android development news, coding and design patterns. Finally a blog I can count on to keep myself updated with latest and greatest things happening in Android world.

Vipul Shah
Android Developer
Microsoft

Become Pro in Android by watching videos

OUR LEARNERS WORK AT