Modifier.clip
is needed if you are supposed chain background, pointerInput
(clickable also a pointerInput), graphicsLayer
or any Modifier
that requires current layer of your Composable. Modifier.clip() is Modifier.graphicsLayer{clip =true shape=shape}
and layer effects physical presence sort of, order of Modifier.graphics also define how your Composable behaves.
On the other hand Modifier.border() is a DrawModifier which has no effect on physical presence of you Composable
Column(
modifier = Modifier
.fillMaxSize()
.padding(20.dp)
) {
Text("Box with Clip and no border shape")
Box(
modifier = Modifier
.clip(CircleShape)
.border(3.dp, Color.Red)
.size(100.dp)
.background(Color.Yellow)
.clickable { }
)
Text("Box with no clip")
Box(
modifier = Modifier
.border(3.dp, Color.Red, CircleShape)
.size(100.dp)
.background(Color.Yellow)
.clickable { }
)
Text("Box with clip and border with shape")
Box(
modifier = Modifier
.clip(CircleShape)
.border(3.dp, Color.Red, CircleShape)
.size(100.dp)
.background(Color.Yellow)
.clickable { }
)
}
