Skip to content

Instantly share code, notes, and snippets.

@ssindher11
Created January 29, 2022 07:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ssindher11/539e22892b42e788730657c9d44d096d to your computer and use it in GitHub Desktop.
Save ssindher11/539e22892b42e788730657c9d44d096d to your computer and use it in GitHub Desktop.
ConstraintLayout(modifier = Modifier.constrainAs(castContainer) {
bottom.linkTo(coverImage.bottom)
start.linkTo(coverImage.end, 16.dp)
end.linkTo(parent.end, 16.dp)
width = Dimension.fillToConstraints
}) {
Image(
painter = painterResource(id = R.drawable.cast1),
contentDescription = null,
contentScale = ContentScale.Crop,
modifier = Modifier
.height(50.dp)
.constrainAs(castImage1) {
top.linkTo(parent.top)
bottom.linkTo(parent.bottom)
start.linkTo(coverImage.end, 16.dp)
}
.aspectRatio(1f)
)
Image(
painter = painterResource(id = R.drawable.cast2),
contentDescription = null,
contentScale = ContentScale.Crop,
modifier = Modifier
.height(50.dp)
.constrainAs(castImage2) {
top.linkTo(castImage1.top)
bottom.linkTo(castImage1.bottom)
start.linkTo(castImage1.end)
}
.aspectRatio(1f)
)
Image(
painter = painterResource(id = R.drawable.cast3),
contentDescription = null,
contentScale = ContentScale.Crop,
modifier = Modifier
.height(50.dp)
.constrainAs(castImage3) {
top.linkTo(castImage1.top)
bottom.linkTo(castImage1.bottom)
start.linkTo(castImage2.end)
}
.aspectRatio(1f)
)
Box(modifier = Modifier
.height(50.dp)
.background(color = colorResource(id = R.color.gray))
.constrainAs(castImage4) {
top.linkTo(castImage1.top)
bottom.linkTo(castImage1.bottom)
start.linkTo(castImage3.end)
end.linkTo(parent.end, 16.dp)
}
.aspectRatio(1f))
{
Text(
text = "+9",
textAlign = TextAlign.Center,
fontSize = 14.sp,
modifier = Modifier
.padding(horizontal = 4.dp)
.align(Alignment.Center),
color = Color.Black
)
}
createHorizontalChain(
castImage1, castImage2, castImage3, castImage4,
chainStyle = ChainStyle.SpreadInside
)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment