mzgreen
04/14/2021, 11:03 AM// first method - result on the left
Canvas(modifier = Modifier.size(50.dp)) {
drawCircle(Color.Blue)
drawCircle(Color.Green, style = Stroke(width = 2.dp.value))
}
/ second method - result on the right
Surface(
shape = CircleShape,
color = Color.Blue,
border = BorderStroke(2.dp, Color.Green),
modifier = Modifier.size(50.dp),
content = {}
)
mzgreen
04/14/2021, 11:20 AMStroke(width = 2.dp.value)
is wrong. 2.dp.value
returns 2 and not pixel value. The correct way would be Stroke(width = 2.dp.toPx())
.
Now it looks almost the same, except for the fact that green circle is outside of composable bounds as you can see on first screenshot. Why is it like this?seb
04/14/2021, 11:26 AMmzgreen
04/14/2021, 11:43 AMmzgreen
04/14/2021, 11:44 AMseb
04/14/2021, 11:46 AMmzgreen
04/14/2021, 11:47 AMAlbert Chang
04/14/2021, 12:14 PMmzgreen
04/14/2021, 12:55 PM