chanjungskim
03/03/2023, 9:17 AMButton(
onClick = {
isPressed = !isPressed
onNotifyButtonState.invoke(index, isPressed)
},
modifier = if (isPressed) {
modifier
.clip(RoundedCornerShape(10.dp))
.background(buttonColor)
.border(1.dp, PressedButtonStroke, buttonShape)
} else {
modifier
.clip(buttonShape)
.background(buttonColor)
}
)
I think it's related to theme but I don't know where I can fix it.Oleksandr Balan
03/03/2023, 9:23 AMButton
has dedicated arguments for shape, color and border, which should be use to adjust it’s style:
Button(
shape = if (isPressed) RoundedCornerShape(10.dp) else buttonShape,
border = if (isPressed) BorderStroke(1.dp, PressedButtonStroke) else null,
colors = ButtonDefaults.buttonColors(buttonColor),
onClick = { ... }
) {
...
}
Or you can adjust them in the material theme if you want to apply it across all your elements. Check https://developer.android.com/jetpack/compose/designsystems/material
Also try to put long code snippets & screenshots in the thread, see https://kotlinlang.slack.com/archives/CJLTWPH7S/p1616265877303000chanjungskim
03/03/2023, 9:52 AM