'Constraints in Jetpack Compose is not working properly
I have a simple Text and Image in the ConstraintLayout in Compose. Here's the code :
@Composable
fun ImageView() {
ConstraintLayout(modifier = Modifier
.fillMaxSize()) {
val (text, image) = createRefs()
Text(text = "Test", color = Color.White, modifier = Modifier.constrainAs(text){
top.linkTo(parent.top)
})
Image(painter = painterResource(id = R.drawable.ic_date), contentDescription = "", modifier = Modifier.constrainAs(image){
top.linkTo(text.bottom)
start.linkTo(anchor = text.start)
})
}
}
I want the image to start exactly from where the text starts. So I gave start.linkTo(anchor = text.start). But this is what I got :
I think the image itself has some space at the start. But I wonder why the constraints don't work. Please help.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|

