Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
S

switchbutton

> 编程语言
Open source

iOS风格SwitchButton。 只涉及到一个类文件,异常容易集成进入你的项目。支持开关的"延时和回滚"操作。only one class file, very easy to integrate into your program. support the delay operation and rolling

685 stars0 likes0 views
WebsiteGitHub

About

SwitchView

Download

DemoApp.apk

Usage

  1. add library

implementation 'com.github.iielse:switchbutton:1.0.5'

  1. xml
  1. activity
switchView.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View v) {
        boolean isOpened = switchView.isOpened();
    }
});

or

switchView.setOnStateChangedListener(new SwitchView.OnStateChangedListener() {
    @Override
    public void toggleToOn(SwitchView view) {
        view.toggleSwitch(true); // or false
    }

    @Override
    public void toggleToOff(SwitchView view) {
        view.toggleSwitch(false); // or true
    }
});

Attributes

attr description
hasShadow 是否显示按钮阴影
primaryColor 开启状态背景色
primaryColorDark 开启状态按钮描边色
offColor 关闭状态描边色
offColorDark 关闭状态按钮描边色
shadowColor 按钮阴影色
ratioAspect 按钮宽高形状比率(0,1] 不推荐大幅度调整
isOpened 初始化默认状态

Issues· 0 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

Javaandroidswitchbutton

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 17, 2026
Category编程语言
PricingOpen source

> Related tools

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言