orangy
03/21/2021, 5:45 PMromainguy
03/21/2021, 8:01 PMorangy
03/21/2021, 8:16 PMjim
03/22/2021, 7:24 AMSergey Y.
03/25/2021, 5:49 PMNader Jawad
03/25/2021, 6:11 PMSergey Y.
03/25/2021, 6:21 PMNader Jawad
03/25/2021, 6:25 PMSergey Y.
03/25/2021, 6:26 PMorangy
03/27/2021, 2:13 PMModifier.clip(RoundedCornerShape(8.dp)).border(BorderStroke(2.dp, Color(0xFF623D15)), RoundedCornerShape(8.dp))
Am I doing something wrong here?<svg width="400" height="180">
<rect x="50" y="20" rx="20" ry="20" width="150" height="150"
style="fill:red;stroke:black;stroke-width:5;opacity:0.5" />
</svg>
I get this, without any issue for the corners.Modifier.border
function. First it adjusts stroke width like val strokeWidth = 1.2f * borderSize
with some long explanation text above which is not entirely clear (to me), and then it draws another rounded rect of hairline width (1px always) on top of it. So I made a copy of this function, removed both hacks, and I see that border has now proper width. But then, there is background visible through antialiased pixels of the border at the corners. I believe, that hackery was introduced to fix this, but I think it’s not really proper way, because of the resulting effect.PaintingStyle.StrokeAndFill
or even get rid of the selector altogether and have PaintingStyle
a data class with nullable stroke and fill brushes. Skia has this PaintMode.STROKE_AND_FILL
but it is unused, so I believe it is impossible to make it via compose. I don’t think it is possible to properly emulate this with separate fill and stroke, due to all the antialiasing.romainguy
03/27/2021, 8:35 PMorangy
03/27/2021, 9:31 PMromainguy
03/27/2021, 9:39 PMorangy
03/27/2021, 9:41 PMromainguy
03/27/2021, 9:42 PMorangy
03/27/2021, 9:44 PM.shape(borderStroke, fillBrush)
instead of separate background and border and clip modifiers… I can do that for myself, of course 🙂Nader Jawad
03/27/2021, 11:22 PMorangy
03/27/2021, 11:33 PMMine
version is better than Compose
above), but I’d really appreciate if compose would do the right thing out of the box. I will also think about adjusting radius for half of stroke size, to adapt for outer/inner, but not sure how to do this properly for radius less then half of stroke width – should it become rectangular at this point? Anyway, my solution works for me.Nader Jawad
03/27/2021, 11:38 PMorangy
03/27/2021, 11:39 PMromainguy
03/28/2021, 12:08 AMorangy
03/28/2021, 12:14 AMromainguy
03/28/2021, 12:16 AMNader Jawad
03/28/2021, 1:43 AMorangy
03/28/2021, 10:55 AMmzgreen
04/15/2021, 8:04 AMNader Jawad
06/07/2021, 6:32 PM