How can I draw a custom curved border around an el...
# compose
l
How can I draw a custom curved border around an element? I need to implement something like this 🧵
image.png
m
you have to create a custom Shape for that. I did something similar. Easiest way, create a path with the bottom nav shape without the cutout. then subtract in the path the fab shape outline
l
Can I subtract the FAB with the padding?
👍 1
m
use fabShape.createOutline(...). add that to a path and use op(bottomNavShape). sth like that. last shape being the your bottom nav without the cutout
l
Thanks, I will try that!
What is
op(bottomNavShape)
?
Is it subtraction?
r
Path.op is the API in the platform, it was added to Compose 1.10 in beta or alpha. Instead you can use Path.minus (or just use the operator: path1 - path2)
thank you color 1
Note that you can also build the shape yourself instead. Going down the route of boolean operations is basically as complicated since you'll have to build a shape that creates all those rounded corners
👍 1
l
Yes, it's probably cleaner to build it as an independent shape. Thank you!