nuhkoca
04/25/2022, 9:59 PMshadow function applies elevation for all edgesKirill Grouchnikov
04/25/2022, 11:07 PMnuhkoca
04/26/2022, 3:25 AM12dpnuhkoca
04/26/2022, 10:14 AMprivate fun Modifier.bottomElevation(): Modifier = this.then(Modifier.drawWithContent {
val paddingPx = 8.dp.toPx()
clipRect(
left = 0f,
top = 0f,
right = size.width,
bottom = size.height + paddingPx
) {
this@drawWithContent.drawContent()
}
})nuhkoca
04/26/2022, 10:22 AMshadow(elevation, clip = false) not working, thoOleksandr Balan
04/26/2022, 2:53 PMSurface , then clipping all sides except bottom should work (border only for illustration):
Surface(
elevation = 16.dp,
modifier = Modifier
.fillMaxWidth()
.border(1.dp, Color.Magenta)
.clip(GenericShape { size, _ ->
lineTo(size.width, 0f)
lineTo(size.width, Float.MAX_VALUE)
lineTo(0f, Float.MAX_VALUE)
})
) {
Text(
text = "Allow only bottom shadow",
modifier = Modifier.padding(16.dp)
)
}nuhkoca
04/26/2022, 3:42 PMBox, not Surface. For Surface, it works but for Box, it is not. I think shadow is not incorporating properlyOleksandr Balan
04/26/2022, 3:56 PMclip should be applied before the shadow modifier:
Box(
modifier = Modifier
.fillMaxWidth()
.clip(GenericShape { size, _ ->
lineTo(size.width, 0f)
lineTo(size.width, Float.MAX_VALUE)
lineTo(0f, Float.MAX_VALUE)
})
.shadow(16.dp)
.background(Color.White)
) {
Text(
text = "Allow only bottom shadow",
modifier = Modifier.padding(16.dp)
)
}nuhkoca
04/26/2022, 4:00 PMnuhkoca
04/26/2022, 4:18 PMclip and shadow are in relation, I still couldn’t figure outOleksandr Balan
04/26/2022, 4:23 PMnuhkoca
04/26/2022, 8:58 PM