Commit 1b06835 1 parent a17e3cf commit 1b06835 Copy full SHA for 1b06835
File tree 1 file changed +13
-0
lines changed
ReactAndroid/src/main/java/com/facebook/react/views/switchview
1 file changed +13
-0
lines changed Original file line number Diff line number Diff line change 8
8
package com .facebook .react .views .switchview ;
9
9
10
10
import android .content .Context ;
11
+ import android .content .res .ColorStateList ;
11
12
import android .graphics .PorterDuff ;
12
13
import android .graphics .drawable .Drawable ;
14
+ import android .graphics .drawable .RippleDrawable ;
15
+ import android .os .Build ;
13
16
import androidx .annotation .Nullable ;
14
17
import androidx .appcompat .widget .SwitchCompat ;
15
18
@@ -59,6 +62,16 @@ public void setTrackColor(@Nullable Integer color) {
59
62
60
63
public void setThumbColor (@ Nullable Integer color ) {
61
64
setColor (super .getThumbDrawable (), color );
65
+
66
+ // Set the ripple color with thumb color if >= LOLLIPOP
67
+ if (Build .VERSION .SDK_INT >= Build .VERSION_CODES .LOLLIPOP ) {
68
+ RippleDrawable ripple = (RippleDrawable ) super .getBackground ();
69
+ ColorStateList customColorState =
70
+ new ColorStateList (
71
+ new int [][] {new int [] {android .R .attr .state_pressed }}, new int [] {color });
72
+
73
+ ripple .setColor (customColorState );
74
+ }
62
75
}
63
76
64
77
/*package*/ void setOn (boolean on ) {
You can’t perform that action at this time.
0 commit comments