implementation 'com.yayaG.iosSwitchButton:iosswitchbutton:1.0.3'
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' }
}
}
<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();
}
});