Hello Team, how we can show icon to end of text i...
# compose
v
Hello Team, how we can show icon to end of text in row when text is large. when text is small then its working perfectly but when text is large then icon is not showing need to show text in single line with icon in end in available row width have to do without constraint layout as its not available in compose multiplatform
Copy code
@Composable
fun VerifiedUserName(
    name: String,
    modifier: Modifier = Modifier
) {

    Row(
        modifier = modifier,
        horizontalArrangement = Arrangement.spacedBy(2.dp)
    ) {
        Text(
            text = name,
            modifier = Modifier,
            maxLines = 1,
            overflow = TextOverflow.Ellipsis,
            style = TextStyle(
                fontFamily = FontFamily(
                    Font(
                        resource = Res.font.poppins_semi_bold
                    )
                ),
                fontSize = 16.sp
            )
        )
        Icon(
            painter = painterResource(Res.drawable.verified_user),
            contentDescription = stringResource(Res.string.address),
            modifier = Modifier.size(16.dp),
            tint = MaterialTheme.colorScheme.primary
        )
    }
}

calling site 
Row(
    modifier = Modifier
        .fillMaxWidth(),
    verticalAlignment = Alignment.CenterVertically
) {


    VerifiedUserName(
        name = name,
        modifier = Modifier
            .weight(1f)
    )

    Text(
        text = code,
        modifier = Modifier
        //.padding(start = 4.dp)
        ,
        fontFamily = FontFamily(
            Font(
                resource = Res.font.poppins_medium
            )
        ),
        fontSize = 12.sp
    )
}
please help thanks in advance
🧵 5
s
If you put a
Modifier.weight(1f)
to your
Text
composable it will take up all of the remaining space, leaving the icon always pushed to the end and never getting cut-off
☝🏼 1
☝️ 1
v
if i put weight(1f) then if text is short, there is space between text and icon, i need icon at end of text
s
Give
.weight(1f, fill = false)
a try
👍 5
v
Thanks for helping, its working
s
Great to see! Read this https://kotlinlang.slack.com/archives/CJLTWPH7S/p1616265877303000 for more info about why you got a 🧵 response.
👍 2
c
3.6k people in this channel has gone up to 17.6k! Nice!
kodee happy 3
💯 2