Created
May 29, 2024 18:00
-
-
Save amodkanthe/728ab70957539e97eebb32443cf44ffb to your computer and use it in GitHub Desktop.
TextView next to each other
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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