I want to remove ripple effect from button, but still have onSurface color on it.
For example, this is button before pressed
i want to achieve this after pressing button.
Here is my current code.
val MyRippleConfiguration =
RippleConfiguration(color = Color.Red, rippleAlpha = RippleAlpha(0f,0f,0f,0f))
CompositionLocalProvider(LocalRippleConfiguration provides MyRippleConfiguration){
Button(
modifier = Modifier.fillMaxWidth().padding(4.dp).bounceClickEffect(),
onClick = {
}) {
Text(
text = "Sign up free",
color = colorResource(id = R.color.black),
fontWeight = FontWeight.Bold,
fontSize = 16.sp
)
}
}
fun Modifier.bounceClickEffect() = composed {
var isPressed by remember { mutableStateOf(false) }
val scale by animateFloatAsState(if (isPressed) 0.98f else 1f)
this
.graphicsLayer {
scaleX = scale
scaleY = scale
}
.pointerInput(isPressed) {
awaitPointerEventScope {
isPressed = if (isPressed) {
waitForUpOrCancellation()
false
} else {
awaitFirstDown(false)
true
}
}
}
}
i tried to change values of RippleAlpha object but i were unable to achieve it.