In my mind, I can draw something inside a canvas when I use Jetpack Compose.
The Code A set a canvas with size(50.dp)
, so I think I can only draw something inside the area.
But I get Image A when I run Code A, the line is out of the area.
Why can I draw a line out of the canvas when I use Jetpack Compose?
Code A
@Composable
fun ScreenHome_Watch(
modifier: Modifier = Modifier
){
Box(
modifier = modifier
) {
Box(
modifier = Modifier.matchParentSize()
) {
Canvas(
modifier = Modifier.size(50.dp).background(Color.Red)
) {
drawLine(
Color.Blue,
start = Offset(0f, 0f),
end = Offset(200f, 200f),
strokeWidth = 5f
)
}
}
}
}
Image A