I've got this little DurationDial that I'm impleme...
# compose
t
I've got this little DurationDial that I'm implementing with some Canvas.DrawScopes. I want the dark cyan circle thumb to pop off, by having a shadow under it. Is there any way to simulate shadows easily in a DrawScope? (I can draw series of successive alpha dark circles below it if I want to get really old fashion primitive), I could also move the thumb into its own composable like a Surface with a CircleShape and a shadow, but then all the drawing code that has already done various center/radius/angle math gets repeated. The second screenshot (purple thumb) is the iOS version with the shadow effect I want to recreate.
r
In this case you can easily fake it by drawing a second circle with a radial (circular) gradient
t
True. What about when I want to do a line or a rectangle? I wish this were a withShadow(values) { } sub draw scope, kind of like withTransform
r
You can use a native Canvas on Android and set a shadow layer on the paint
that will work on Android P and above
a
Copy code
Paint().apply { color = Color.Black }.asFrameworkPaint().setShadowLayer()
And then draw whatever you want with this paint
r
Yep, that
t
i'll give that a try, thanks. i need to use the native draw methods inside the native scope in that case (rather than drawCircle, etc), correct?
r
Yeah but they are basically the same
like drawCircle() for circles 😄
t
This worked like a charm, thanks!
e
Damn, why does the ios font (make the entire thing) look better 🧌 (🙈)
t
maybe in part, because I have the font size on the android one cranked up bigger. that said, for me, it has something to do with weight. SF seems to have a marginally thicker nominal stroke weight that gives the font more solidity. i have experimented with weight on roboto to try and get it to match, because at a glance they are similiar. but the SF normal weight seems to be somewhere between that of Roboto's normal and medium
👍🏾 1
r
You can rely on variable fonts to fine tune your weight btw
1