1、switchbutton是项目开发中常用的开关控件,可直接引用系统中的switchbutton,刚刚写了一个小demo,研究了一下switchbutton中的一些常用属性:
- swThumbDrawable: drawable of thumb(按钮的图像)
- swThumb_margin: set inner margin between thumb and edges
- swThumb_marginLeft/Top/Bottom/Right: set margin for specific edge
- swThumb_width: set the width of thumb, probably used for gradient drawable(按钮的宽)
- swThumb_height: set the height of thumb(按钮的高)
- swThumbColor: like the onColor(按钮的颜色,默认为灰色,打开时根据类型所定)
- swMeasureFactor: factor limit the minimum width equals almost (the height of thumb * measureFactor)(拇指高度)
- swTextOn:按钮开始时显示的内容
- swTextOff:按钮关闭的时显示的内容
- swBackColor:开关背景色
- swBackDrawable:开关背景图片
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" tools:context="com.example.wls.myswitchbutton.MainActivity"> <com.alanapi.switchbutton.SwitchButton android:id="@+id/switchButton1"