Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save amodkanthe/728ab70957539e97eebb32443cf44ffb to your computer and use it in GitHub Desktop.
Save amodkanthe/728ab70957539e97eebb32443cf44ffb to your computer and use it in GitHub Desktop.
TextView next to each other
@Preview
@Composable
fun ConstraintLayoutView() {
ConstraintLayout(modifier = Modifier.fillMaxSize()) {
val (textTitle, textMore) = createRefs()
Text(
"This is a long title This is a long title This is a long title This is a long title",
modifier = Modifier.constrainAs(textTitle) {
top.linkTo(parent.top, margin = 8.dp)
start.linkTo(parent.start, margin = 8.dp)
end.linkTo(textMore.start, 8.dp)
width = Dimension.fillToConstraints
}
)
Text(
"Show More",
color = Color.Blue.copy(alpha = 0.5f),
modifier = Modifier.constrainAs(textMore) {
top.linkTo(parent.top, margin = 8.dp)
end.linkTo(parent.end, margin = 8.dp)
}
)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment