https://kotlinlang.org logo
#compose
Title
# compose
y

Yuri Drigin

07/19/2021, 2:49 PM
Hi folks! I need to set priority (content resistance) to item in
Row
but cannot figure out how to do it. For sample I have few texts in Row, but I need truncate the first one for sample, not the last
weight
isn’t correct way to do it Thanks
a

Adam Powell

07/19/2021, 3:00 PM
are you avoiding weight because you don't want it to fill the full available space or for some other reason?
y

Yuri Drigin

07/19/2021, 3:11 PM
weight don’t do it as I need. At least for text.
a

Adam Powell

07/19/2021, 3:12 PM
how so? I ask because people don't always find the
fill
optional parameter to
weight
, and setting it to
false
avoids filling the whole space but it does lower the element's measurement priority so that other siblings measure first.
🙌 1
y

Yuri Drigin

07/19/2021, 3:23 PM
Copy code
Row(
    modifier = Modifier.fillMaxWidth(),
    horizontalArrangement = Arrangement.spacedBy(8.dp)
) {
    Text(
        text = walletName,
        style = MaterialTheme.typography.body1,
        maxLines = 1,
        overflow = TextOverflow.Ellipsis,
    )
    Text(
        text = amount,
        modifier = Modifier
            .weight(1f, fill = true),
        style = FormularMonoTypography.body2,
        maxLines = 1,
    )
}
May be I wrong but it’s not as priority.
a

Adam Powell

07/19/2021, 3:25 PM
set weight on the lower priority item - the
walletName
text.
y

Yuri Drigin

07/19/2021, 3:25 PM
+
from amount - only first symbol
a

Adam Powell

07/19/2021, 3:26 PM
unweighted children measure first
y

Yuri Drigin

07/19/2021, 3:27 PM
Yep. It need to truncated walletName if space not enough
So you offer to put
Copy code
Modifier.weight(1f, fill = false)
on the walletName?
👍 1
Let me check
@Adam Powell Thanks a lot. It help. You right. I didn’t consider
fill = false
yearly
👍 1
4 Views