Is there any way to implement a gradient like this...
# compose
y
Is there any way to implement a gradient like this? I tried using radial gradient but without success. I ended up drawing each line manually with a decay from the original color to full transparency. It's far from ideal but it's for a scrim so it does the job.
c
how'd you get it rounded drawing it manually that way?
y
Calling
n
times
drawRoundRect
by contracting the rect each call where
n
is the number of gradient steps 😅 Each step is slightly more transparent each time
c
wow haha
without roundness you could use linear gradients with transparency going inward for each side
y
Yup, but I need the corner radius for the scrim to be "smooth"
c
someone who knows more than me may be able to provide an actually good answer, but for some more complicated details I have just been using svgs, they can still losselessly scale, can be more easily edited when compared with very complicated compose code and don't perform so bad
y
Didn't think of that, creating such a gradient is probably easy with illustrator or whatever, and I can then use the SVG as a background. The only drawback is that the aspect ratio needs to be known in advance if I don't want the corner radius to be stretched
c
yeah, maybe not though? normal svgs can have rectangles with fixed rounded edges, also for more advanced shapes you can use relative coordinates to describe shapes. not sure about android ones though. I reckon these would be defaults or represented somehow in most design tools
also I recommend Figma if you're not already an illustrator fan, it's free and great
g
Maybe just 9-patch? :)