Apoorv Patel
10/15/2020, 4:40 PMConstraintLayout
but i am not able to get the constraints to work properly.
ConstraintLayout(modifier = Modifier.padding(top = 16.dp, bottom = 16.dp)) {
val (profileImage, progressText1) = createRefs()
Image(
modifier = Modifier
.constrainAs(profileImage){
start.linkTo(parent.start, 16.dp)
}.preferredWidth(72.dp)
.preferredHeight(72.dp)
.background(Color.Green),
asset = imageResource(R.drawable.unknown_profile_empty)
)
val half = createGuidelineFromTop(0.5f)
Text(text = "Sample text", modifier = Modifier.background(Color.Red).constrainAs(progressText1) {
bottom.linkTo(half, 0.dp)
start.linkTo(profileImage.end, 0.dp)
end.linkTo(parent.end, 16.dp)
})
}
I am expecting that the text will align itself to the image end but it is not aligned to thatHitanshu Dhawan
10/15/2020, 4:50 PMend.linkTo(parent.end, 16.dp)
Here, it is having start and end constraints, so it is centred from image end and parent end.apoorv9990
10/15/2020, 5:24 PMHitanshu Dhawan
10/15/2020, 5:45 PMText(text = "Sample text", modifier = Modifier.background(Color.Red).constrainAs(progressText1) {
bottom.linkTo(half, 0.dp)
start.linkTo(profileImage.end, 0.dp)
end.linkTo(parent.end, 16.dp)
width = Dimension.fillToConstraints
})
width = Dimension.fillToConstraints
Apoorv Patel
10/16/2020, 2:59 AM