File tree Expand file tree Collapse file tree
SwitchButton/demo/src/main
java/com/kyleduo/switchbutton/demo Expand file tree Collapse file tree Original file line number Diff line number Diff line change 22
33import android .os .Bundle ;
44import android .support .v7 .app .ActionBarActivity ;
5+ import android .widget .CompoundButton ;
56
67import com .kyleduo .switchbutton .SwitchButton ;
78
89public class StyleActivity extends ActionBarActivity {
910
10- private SwitchButton mChangeSb ;
11+ private SwitchButton mChangeSb , mFlymeSb , mMiuiSb ;
1112
1213 @ Override
1314 protected void onCreate (Bundle savedInstanceState ) {
1415 super .onCreate (savedInstanceState );
1516 setContentView (R .layout .activity_style );
1617
1718 mChangeSb = (SwitchButton ) findViewById (R .id .sb_code );
19+ mFlymeSb = (SwitchButton ) findViewById (R .id .sb_custom_flyme );
20+ mMiuiSb = (SwitchButton ) findViewById (R .id .sb_custom_miui );
21+
22+ mChangeSb .setOnCheckedChangeListener (new CompoundButton .OnCheckedChangeListener () {
23+ @ Override
24+ public void onCheckedChanged (CompoundButton buttonView , boolean isChecked ) {
25+ mFlymeSb .setEnabled (isChecked );
26+ mMiuiSb .setEnabled (isChecked );
27+ }
28+ });
1829 }
1930
2031}
Original file line number Diff line number Diff line change 11<?xml version =" 1.0" encoding =" utf-8" ?>
2- <shape xmlns : android =" http://schemas.android.com/apk/res/android" >
3- <solid android : color =" #FBFBFB" />
4- <corners android : radius =" 99dp" />
5- <stroke
6- android:width=" 1dp"
7- android:color=" #D0D0D0" />
8- </shape >
2+ <selector xmlns : android =" http://schemas.android.com/apk/res/android" >
3+ <item android : state_enabled =" false" >
4+ <shape >
5+ <solid android : color =" #FBFBFB" />
6+ <corners android : radius =" 99dp" />
7+ <stroke
8+ android:width=" 1dp"
9+ android:color=" #DEDEDE" />
10+ </shape >
11+ </item >
12+ <item >
13+ <shape >
14+ <solid android : color =" #FBFBFB" />
15+ <corners android : radius =" 99dp" />
16+ <stroke
17+ android:width=" 1dp"
18+ android:color=" #D0D0D0" />
19+ </shape >
20+ </item >
21+ </selector >
Original file line number Diff line number Diff line change 11<?xml version =" 1.0" encoding =" utf-8" ?>
22<selector xmlns : android =" http://schemas.android.com/apk/res/android" >
3+ <item android : state_checked =" true" android : state_enabled =" false" >
4+ <shape android : shape =" oval" >
5+ <solid android : color =" #B8E2F8" />
6+ </shape >
7+ </item >
38 <item android : state_enabled =" false" >
49 <layer-list >
5- <item android : bottom =" 6dp" android : left =" 2dp " android : right =" 2dp " android : top =" 6dp" >
10+ <item android : bottom =" 6dp" android : left =" 4dp " android : right =" 4dp " android : top =" 6dp" >
611 <shape >
7- <solid android : color =" #AAAAAA " />
12+ <solid android : color =" #DEDEDE " />
813 <corners android : radius =" 1dp" />
914 </shape >
1015 </item >
1520 <solid android : color =" #28A4E9" />
1621 </shape >
1722 </item >
18- <layer-list >
19- <item android : bottom =" 6dp" android : left =" 2dp" android : right =" 2dp" android : top =" 6dp" >
20- <shape >
21- <solid android : color =" #AAAAAA" />
22- <corners android : radius =" 1dp" />
23- </shape >
24- </item >
25- </layer-list >
23+ <item >
24+ <layer-list >
25+ <item android : bottom =" 6dp" android : left =" 4dp" android : right =" 4dp" android : top =" 6dp" >
26+ <shape >
27+ <solid android : color =" #D0D0D0" />
28+ <corners android : radius =" 1dp" />
29+ </shape >
30+ </item >
31+ </layer-list >
32+ </item >
2633</selector >
Original file line number Diff line number Diff line change 11<?xml version =" 1.0" encoding =" utf-8" ?>
2- <shape xmlns : android =" http://schemas.android.com/apk/res/android" >
3- <solid android : color =" #F8F8F8" />
4- <corners android : radius =" 99dp" />
5- <stroke
6- android:width=" 1px"
7- android:color=" #BABABA" />
8- </shape >
2+ <selector xmlns : android =" http://schemas.android.com/apk/res/android" >
3+ <item android : state_enabled =" false" >
4+ <shape >
5+ <solid android : color =" #F8F8F8" />
6+ <corners android : radius =" 99dp" />
7+ <stroke
8+ android:width=" 1px"
9+ android:color=" #DEDEDE" />
10+ </shape >
11+ </item >
12+ <item >
13+ <shape >
14+ <solid android : color =" #F8F8F8" />
15+ <corners android : radius =" 99dp" />
16+ <stroke
17+ android:width=" 1px"
18+ android:color=" #BABABA" />
19+ </shape >
20+ </item >
21+ </selector >
Original file line number Diff line number Diff line change 11<?xml version =" 1.0" encoding =" utf-8" ?>
22<selector xmlns : android =" http://schemas.android.com/apk/res/android" >
3+ <item android : state_enabled =" false" android : state_checked =" true" >
4+ <shape android : shape =" oval" >
5+ <solid android : color =" #FFA75E" />
6+ <stroke
7+ android:width=" 1px"
8+ android:color=" #DB8056" />
9+ </shape >
10+ </item >
311 <item android : state_enabled =" false" >
412 <shape android : shape =" oval" >
5- <solid android : color =" #E0E0E0 " />
13+ <solid android : color =" #E1E1E1 " />
614 <stroke
715 android:width=" 1px"
8- android:color=" #D0D0D0 " />
16+ android:color=" #ECECEC " />
917 </shape >
1018 </item >
1119 <item android : state_checked =" true" >
You can’t perform that action at this time.
0 commit comments