alexsullivan114
05/11/2021, 4:07 PMshadow
modifier as follows:
@Composable
@Preview
private fun ProfileItem() {
Box(modifier = Modifier.background(Color.White).padding(20.dp)) {
Image(
painter = painterResource(id = R.drawable.charles),
contentScale = ContentScale.Crop,
contentDescription = "Profile Image",
modifier = Modifier
.size(48.dp)
.shadow(8.dp, CircleShape)
)
}
}
This results in a circular avatar-esque image, but there's no shadow.
However, if I swap out the Image
Composable with a Text
Composable, I see a shadow:
@Composable
@Preview
private fun ProfileItem() {
Box(modifier = Modifier.background(Color.White).padding(20.dp)) {
Text("Testing shadow", modifier = Modifier.size(48.dp).shadow(8.dp, CircleShape))
}
}
I've tried playing around with padding, nesting boxes, and using a surface instead of the shadow modifier, all without any luck.
I'm sure I'm missing something obvious - any ideas?Chris Sinco [G]
05/11/2021, 4:18 PMalexsullivan114
05/11/2021, 4:19 PMalexsullivan114
05/11/2021, 4:22 PMChris Sinco [G]
05/11/2021, 4:22 PMChris Sinco [G]
05/11/2021, 4:24 PMChris Sinco [G]
05/11/2021, 4:24 PMChris Sinco [G]
05/11/2021, 4:25 PMalexsullivan114
05/11/2021, 4:27 PMalexsullivan114
05/11/2021, 4:27 PMalexsullivan114
05/11/2021, 4:28 PMalexsullivan114
05/11/2021, 4:28 PMalexsullivan114
05/11/2021, 4:29 PMChris Sinco [G]
05/11/2021, 4:29 PMChris Sinco [G]
05/11/2021, 4:30 PMChris Sinco [G]
05/11/2021, 4:32 PMMaybe I’m just kind of blind?Ha no I think the challenge with the shadow system is it’s based on the elevation value, so sometimes it’s not always clearly there when it’s actually there. We don’t have an easy way right now to make the shadow more obvious at the moment (related thread)
alexsullivan114
05/11/2021, 4:36 PMChris Sinco [G]
05/11/2021, 5:01 PMAnother thing I’m not really grokking is like how to make the shadow more intense.Yeah it’s not as straightforward as other systems like CSS but for a reason (see linked thread with response from Romain)
Chris Sinco [G]
05/11/2021, 5:01 PMromainguy
05/11/2021, 5:05 PMromainguy
05/11/2021, 5:08 PMromainguy
05/11/2021, 5:09 PMromainguy
05/11/2021, 5:09 PMromainguy
05/11/2021, 5:09 PMromainguy
05/11/2021, 5:09 PMromainguy
05/11/2021, 5:09 PMromainguy
05/11/2021, 5:09 PMromainguy
05/11/2021, 5:10 PMChris Sinco [G]
05/11/2021, 5:15 PMromainguy
05/11/2021, 5:17 PMromainguy
05/11/2021, 5:17 PMromainguy
05/11/2021, 5:18 PMHardwareRenderer
romainguy
05/11/2021, 5:19 PMval renderer = HardwareRenderer()
renderer.setSurface(targetSurface)
renderer.setContentRoot(rootRenderNode)
// Ambient shadow, direct shadow
renderer.setLightSourceAlpha(0.1f, 0.5f)
// Position X, Y, Z, radius
renderer.setLightSourceGeometry(
width() / 2f, 0f, toPx(600f), toPx(800f))
alexsullivan114
05/11/2021, 5:38 PMalexsullivan114
05/11/2021, 5:39 PMalexsullivan114
05/11/2021, 5:39 PMromainguy
05/11/2021, 6:04 PM