I'm having trouble getting a `Text` composable con...
# compose-android
m
I'm having trouble getting a
Text
composable containing an email to display as much of the email as will fit. I thought
TextOverflow.Visible
would give me what I wanted, but it is clipping off the entire ".com" part of the email as soon as it overflows just like
TextOverflow.Clip
. 🤔
Copy code
Box(Modifier.width(200.dp)) {
    Text(
        text = "<mailto:0123456789@gmail.com|0123456789@gmail.com>",
        maxLines = 1,
        overflow = TextOverflow.Visible,
    )
}
I was surprised to see that
TextOverflow.Ellipsis
gave me more of the content than
TextOverflow.Visible
.
c
Whats the intended result?
do you want it to wrap to next line?
or is your issue just "why is it truncated so early?"
m
or is your issue just "why is it truncated so early?"
Yes, that. I'd like it to show something like "0123456789@gmail.co" instead of truncating at the "."
c
I think that might just be the nature of truncation trying to be smart? (i know ive had similar issues with hyphenation in the past) cc @Siyamed ?
k
New mode - when you get close to running out of space, make each subsequent glyph 10% smaller than the previous one
m
That's what everyone wants, right? 😆 FWIW, the reason I want the text to run up to the very end is because I'm using a gradient fade to show overflow.
c
Interesting. makes sense as a usecase. i wonder if the issue is the . like if you remove the . in gmail... does everything work fine?
m
That's right, the issue seems to be the period. If I just pass in a long number it works like I would like.
c
yeah. sounds like the hyphenation issue i had. not sure what your solution will be. sorry. but hopefully siyamed can chime in!
a
Not answering your original question, but to achieve what you want you can apply
Modifier.wrapContentWidth(align = Alignment.Start, unbounded = true)
on the
Text
.
s
Do we have softwrap or singleline in Text? I know we had softwrap; softwrap should do
MaxLines is max number of text limne. Your text becomes two lines and second line is clipped.
Just check material.Text has softwrap, set it to false if you want to prevent any auto lone breaking.
m
Thanks so much for your help! I ended up using
softWrap
, which worked perfectly. 🎉
wrapContentWidth
also worked well, it just didn't work as well as
softWrap
for me.
c
Nice. TIL of softWrap lol