I want to show a custom Indication when a button is clicked. The indication should be rounded in the corners and overlay a darker color. So far I was able to achieve this with the following code
Modifier.clickable(onClick = {}, indication = PressedIndication)
object PressedIndication : Indication {
private object DefaultIndicationInstance : IndicationInstance {
override fun ContentDrawScope.drawIndication(interactionState: InteractionState) {
drawContent()
if (interactionState.contains(Interaction.Pressed)) drawRoundRect(
cornerRadius = CornerRadius(4f, 4f), //<-- How to use dp values?
color = Color.Black.copy(
alpha = 0.3f
), size = size
)
}
}
override fun createInstance(): IndicationInstance {
return DefaultIndicationInstance
}
}
I can achieve rounded corners using drawRoundRect
and cornerRadius
but is there any way to use dp
values?
Note: I cannot use clickable
and clip
because the clickable area doesn't exactly match the indication area