https://kotlinlang.org logo
#compose
Title
# compose
c

chanjungskim

03/03/2023, 9:17 AM
I don't use primary color and don't apply radius for the primary color area. How can I remove the primary color and the radius here?
Copy code
Button(
            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.
o

Oleksandr Balan

03/03/2023, 9:23 AM
Button
has dedicated arguments for shape, color and border, which should be use to adjust it’s style:
Copy code
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/p1616265877303000
c

chanjungskim

03/03/2023, 9:52 AM
I solved this thank you!
6 Views