Hi guys, I have a question. How to custom a Button...
# compose
p
Hi guys, I have a question. How to custom a Button with state color like XML <selector> normal, press, disable...
k
Compose does not have color state lists by design. Instead, you can track the individual state bits (enabled, pressed, hovered, selected, etc) and choose the color that matches the specific combination of those bits. See how it is done in the
material3
library as one example.
k
you can use
ButtonDefaults.buttonColors()
and change the colors in material3 you have
containerColor, contentColor, disabledContainerColor, disabledContentColor
for pressed you normally use a ripple effect, same for hover
z
MutableInteractionSource is your friend here
1
p
Thank for answers. I need custom more stroke, corner... Can you share the example code?
k