Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to put 3 texts in a row so that everything is visible

I’m implementing a screen in Jetpack Compose.
The thing I want to achieve is one row with three Text components next to each other so they fit the whole Row.
First is a label, last is counter and in middle, there is the text that can have different lengths. I would like to always show label and counter, and between them the text, if there is no enough space i would like to wrap it to another line.

Something like on the image below:
what i want to achive

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

Screeshot

Code

@Composable
fun RowExample() {
    Row(
        modifier = Modifier.fillMaxWidth(),
    ) {
        Text(
            text = "Label",
            color = Red,
            style = typography.h5,
            modifier = Modifier.padding(8.dp),
        )
        Text(
            text = "If text is too long, wrap it",
            style = typography.h5,
            modifier = Modifier
                .weight(1f)
                .padding(8.dp),
        )
        Text(
            text = "(2)",
            color = Green,
            style = typography.h5,
            modifier = Modifier.padding(8.dp),
        )
    }
}
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading