All Projects → ronghao → SwitchButton

ronghao / SwitchButton

Licence: other
类似ios效果的滑动按钮,支持自定义背景,动画效果,渐变效果

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to SwitchButton

ThreeStateSwitch
A simple three-state switch view for Android.
Stars: ✭ 28 (+40%)
Mutual labels:  switchbutton
Switchbutton
A cute widget of Switch Button for you to create beautiful and friendly UI.
Stars: ✭ 4,531 (+22555%)
Mutual labels:  switchbutton

SwitchButton GitHub license Download

类似ios效果的滑动按钮,支持自定义背景,动画效果,渐变效果

示例

例子

功能

  • 可自定义背景和游标图片
  • 动画效果:滑动动画,颜色渐变
  • 背景变灰
  • 可支持手势滑动一半退回效果
  • 支持禁用模式

项目添加方法

在根 build.gradle中添加

allprojects {
	repositories {
		...
		maven { url 'https://jitpack.io' }
	}
}

在项目build.gradle中添加

dependencies {
    compile 'com.github.ronghao:SwitchButton:1.0.5'
}

XML代码

<com.haohao.switchbutton.SwitchButton
    android:id="@+id/switchbutton"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    switchbutton:switchbackground="@drawable/switch_bg"
    switchbutton:switchcursor="@drawable/switch_white" />

Attributes

<attr name="switchbackground" format="reference"/>       自定义背景图片
<attr name="switchcursor" format="reference"/>           自定义图片

方法简介

setStatus 设置开启关闭
setStatusImmediately 设置开启关闭(无动画)
setOnSwitchChangeListener 设置滑动开关监听
setSwitchEnabled 设置是否可用

图片示例

名称 图片样式
背景图片 例子
游标图片(图片纯白做了特殊处理) 例子

版本

  • 1.0.5
    • 添加类似IOS 滑动选择效果
  • 1.0.1
    • 添加不可用设置
  • 1.0.0
    • 添加基本效果

关于

  • 个人博客:www.haohaohu.com
  • 如果你也喜欢这个库,Star一下吧,欢迎Fork

License

Copyright 2016 haohaohu

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].