How can I set the shadow offset in graphicsLayer? ...
# compose
k
How can I set the shadow offset in graphicsLayer? The top shadow of components at the bottom of the screen is almost invisible. I want to fix the shadow offset.
s
Short answer: you can’t. Elevation has some limitations, it uses a
fixed-position spot light source
, positioned above the center of the screen, and changing it requires private APIs. In general, use the new shadow API modifiers(
dropShadow
,
innerShadow
) introduced in recent Compose versions. They’re much more configurable. https://medium.com/android-news/mastering-shadows-in-android-e883ad2c9d5b
❤️ 1
k
If I use drop shadow, how about its performance?
s
I haven’t used them much, but I reviewed the implementation. It’s pretty good, it has a caching system, uses brushes and the canvas efficiently, and nothing caught my attention that might cause performance issues.
👍 1
k
Thanks, it works perfectly!
❤️ 3
t
This article have some very cool graphics of how each component is positioned on top of each other. Really cool.