Changing Ripple Color Jetpack Compose
Published:
- Make a class that implements
RippleTheme
Sample:
class CustomRippleTheme(private val rippleColor: Color) : RippleTheme {
//Your custom implementation...
@Composable
override fun defaultColor() =
RippleTheme.defaultRippleColor(
rippleColor,
lightTheme = MaterialTheme.colors.isLight
)
@Composable
override fun rippleAlpha(): RippleAlpha =
RippleTheme.defaultRippleAlpha(
rippleColor.copy(alpha = 0.75f),
lightTheme = MaterialTheme.colors.isLight
)
}
- Wrap your component that you want to be clicked with
CompositionLocalProvider
, asssociate a CompositionLocal key toYourCustomRippleTheme
as a value in thevalues
argument
CompositionLocalProvider(LocalRippleTheme provides CustomRippleTheme(color: DesiredColor){
//your composable (component)
}
- If it is not a
Button
you can addclickable{}
Modifier, no need to add other arguments
modifier = Modifier.clickable{}