安卓仿IOS SwitchButton,增加效果体验

开源地址:
https://github.com/YaYaG/IOSSwitchButton

效果图

在这里插入图片描述

引入依赖 App依赖:

app项目中build.gradle添加:

    implementation 'com.yayaG.iosSwitchButton:iosswitchbutton:1.0.3'
    

在主项目中的build.gradle添加

    maven { url 'https://dl.bintray.com/wangjinya/maven' }
allprojects {
    repositories {
        google()
        jcenter()
        maven { url 'https://maven.google.com' }
        maven { url 'https://dl.bintray.com/wangjinya/maven' }
    }
}

在 maven 中配置如下

    <dependency>
    	<groupId>com.yayaG.iosSwitchButton</groupId>
    	<artifactId>iosswitchbutton</artifactId>
    	<version>1.0.3</version>
    	<type>pom</type>
    </dependency>

属性含义:

check : 是否开启
switchColor :switch圆形颜色
check_color : 选中颜色
uncheck_color :未选中颜色
disable :禁止切换

布局写法

<com.jackwang.ioscheck.IOSSwitchButton
        android:id="@+id/ios_switch"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        app:check="true"
        />
<com.jackwang.ioscheck.IOSSwitchButton
        android:id="@+id/ios_switch2"
        android:layout_width="50dp"
        android:layout_height="50dp"
        android:layout_marginTop="10dp"
        android:clickable="false"
        app:switchColor="#FFF"
        app:check_color="#2196F3"
        app:uncheck_color="#DDDDDD"
        app:check="true"
        app:disable="false"
        />
监听是否选中还非选中:
iosSwitchButton.setSwitchListener(new SwitchListener() {
            @Override
            public void changeCheck(boolean check) {
                Toast.makeText(MainActivity.this, check ? "开启" : "关闭", Toast.LENGTH_SHORT).show();
            }
        });
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值