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

zalewski.se

03/13/2022, 8:58 AM
Any idea what would cause a shadow around card composable appear with like a thick black border? In the preview or if I try the same in another app, it looks correct 🤔
Copy code
Card(
    shape = RoundedCornerShape(8.dp),
    elevation = 10.dp
)
c

Colton Idle

03/13/2022, 4:11 PM
Do you have any more code to show? What composable is this composable nested in?
z

zalewski.se

03/13/2022, 4:19 PM
Basically just in the Column, something like:
Copy code
Column(
    modifier = modifier
        .fillMaxSize()
        .background(Color.White)
) {
    Card(
        shape = RoundedCornerShape(8.dp),
        elevation = 10.dp
    )
}
c

Colton Idle

03/13/2022, 4:25 PM
Anything in your theme or something? The fact that you say that if you try in another app and it works seems to point that some wrapper composable/theme is the culprit
👍 1
z

zalewski.se

03/13/2022, 5:34 PM
I was thinking about theme too but it’s like a first composable in the whole app, I tried to wrap it in
MaterialTheme
but result was the same. Although there is a custom theme set in `AndroidManifest`… 💭
c

Colton Idle

03/13/2022, 5:35 PM
If you could upload the entire project or gist that repos the issue I'll try it on my end.
z

zalewski.se

03/13/2022, 10:13 PM
Unfortunately I can’t share the project. This shadow style is definitely coming from the application theme setting in
AndroidManifest
, I just need to find out which flag is it 😬. I’m quite surprised that wrapping the composable into
MaterialTheme
doesn’t override it though
found in sources:
Copy code
* The opacity of the final ambient shadow is a function of the shadow caster height, the
     * alpha channel of the [ambientShadowColor] (typically opaque), and the
     * [android.R.attr.ambientShadowAlpha] theme attribute.
c

Colton Idle

03/14/2022, 1:21 PM
Nice find!
c

Chris Sinco [G]

03/15/2022, 8:54 AM
Yeah sharing the theme and the Composable parent would be useful to help diagnose things further
z

zalewski.se

03/17/2022, 6:13 PM
The reason
ambientShadowAlpha
was changed is described here. I have quite a mix feeling now about adopting Compose to an existing app (especially really big ones), relaying on an XML based settings in such way can be really hard to find later on.
5 Views