diff --git a/ReactAndroid/src/main/java/com/facebook/react/views/switchview/ReactSwitch.java b/ReactAndroid/src/main/java/com/facebook/react/views/switchview/ReactSwitch.java index 1a2afde1eede3d..4819bf2abd94e1 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/views/switchview/ReactSwitch.java +++ b/ReactAndroid/src/main/java/com/facebook/react/views/switchview/ReactSwitch.java @@ -8,8 +8,11 @@ package com.facebook.react.views.switchview; import android.content.Context; +import android.content.res.ColorStateList; import android.graphics.PorterDuff; import android.graphics.drawable.Drawable; +import android.graphics.drawable.RippleDrawable; +import android.os.Build; import androidx.annotation.Nullable; import androidx.appcompat.widget.SwitchCompat; @@ -59,6 +62,16 @@ public void setTrackColor(@Nullable Integer color) { public void setThumbColor(@Nullable Integer color) { setColor(super.getThumbDrawable(), color); + + // Set the ripple color with thumb color if >= LOLLIPOP + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { + RippleDrawable ripple = (RippleDrawable) super.getBackground(); + ColorStateList customColorState = + new ColorStateList( + new int[][] {new int[] {android.R.attr.state_pressed}}, new int[] {color}); + + ripple.setColor(customColorState); + } } /*package*/ void setOn(boolean on) {