Dan Peluso
05/16/2022, 2:56 PMButton(
colors = ButtonDefaults.buttonColors(
backgroundColor = Colors.White10
),
modifier = Modifier
.clip(RoundedCornerShape(.5.radiusDp))
) { // a single text in the button with only text color declared
Dan Peluso
05/16/2022, 2:56 PMKirill Grouchnikov
05/16/2022, 2:58 PMWhite10
a fully opaque color?Dan Peluso
05/16/2022, 2:59 PMColor(0x1AFFFFFF)
Kirill Grouchnikov
05/16/2022, 3:02 PMDan Peluso
05/16/2022, 3:05 PMButton(
onClick = { },
colors = ButtonDefaults.buttonColors(
backgroundColor = Color(0x1AFFFFFF) // white 10% alpha
),
modifier = Modifier
.clip(RoundedCornerShape(.5.radiusDp))
) {
Text(
text = "Today",
color = Color.White
)
}
Oleksandr Balan
05/16/2022, 3:25 PMfun elevation(
defaultElevation: Dp = 2.dp,
pressedElevation: Dp = 8.dp,
disabledElevation: Dp = 0.dp,
hoveredElevation: Dp = 4.dp,
focusedElevation: Dp = 4.dp,
)
You could disable it by setting to `null`:
Button(
elevation = null,
)
Then the issue will gone.
I am not sure if it possible to have shadows for semi-transparent surfaces 🤷Kirill Grouchnikov
05/16/2022, 3:26 PMDan Peluso
05/16/2022, 5:26 PMTobias Suchalla
05/17/2022, 5:42 AMcolors = ButtonDefaults.buttonColors(
backgroundColor = Colors.White10.compositeOver(backgroundColor)
),
which effectively gives the button a solid color and thus a working shadow.Tobias Suchalla
05/17/2022, 5:48 AMModifier.clip(RoundedCornerShape(.5.radiusDp)
, you should use the button's shape
parameter:
Button(
onClick = { },
colors = ButtonDefaults.buttonColors(
backgroundColor = Colors.White10.compositeOver(backgroundColor)
),
shape = RoundedCornerShape(.5.radiusDp)
) {
Text(
text = "Today",
color = Color.White
)
}
Clipping is more expensive than drawing the shape directly (Link).