Second question is: How can I make the text "as sm...
# compose
n
Second question is: How can I make the text "as small as possible in the width size" without taking the extra space on the sides ? I want the background in pink to be as "close to the text" as possible
Copy code
Box(
    modifier = Modifier.fillMaxSize(),
    contentAlignment = Alignment.Center
) {
    Text(
        modifier = Modifier
            .padding(16.dp)
            .background(Color.Magenta),
        text = "Some long teeeeeext",
        fontSize = 40.sp,
        textAlign = TextAlign.Center,
    )
}
Result of this code [1] I tried
.width(IntrinsicSize.Min)
but it makes the text "too small" (displaying only one word per line) [2] Desired result [3]
I found this issue about the same issue that I have... that is almost 4 years old 😱 There's a shady workaround but I don't really have a choice now. Compose still not prod ready 4 years laters -_-
🙄 2
g
Workaround from SO is indeed not great, do not rely on subcomposition, just measure text as suggested on the comment #32 on google issue tracker
it really depends what you are trying to do of course, but no, it doesn't make it "not ready for production" for god sake, it's totally reasonable usage of custom layout and text measurement
☝🏻 1
n
All I can say is it was easy to do and well documented in Android. In Compose, even after 4 years of "production readiness", it's hard / unreliable to mimic the same behavior as before. That's what we call a regression. Known by Google and untouched for 4 years. And we've got plenty like that. Even simply going "too high" in
sp
breaks the rendering for some reason 🤦. Everytime I have a "not Hello World" design I have to put extra estimations points for it (and usually, the designer makes a "blander copy" for Android) because Compose is not reliable for complexe usecases. I have to find obscure fixes and workarounds to make it happen (thank you folks btw, you are the real heroes of Compose!). But please, that's not what I call prod ready. Stable API signature ? Yes. But it doesn't make it prod ready if it's full of regressions. It's OK to say Compose is not prod ready, there's still so much @ExperimentalXXX stuff going on, completely broken @Composables (I'm looking at you
HorizontalPager
). All I want to say is that even today, Compose is not a smooth ride. So 4 years ago? Hell no it wasn't prod ready.
👎🏿 1
👎 2
g
It's not okay, because it's not true, many thousands apps use it, we use it for years on prod, with great success, and the fact that you can easily do this with compose already shows how ready it is for production
🤫 1
n
We don't have the same definition of "prod ready" then, and that's OK. I want a non-regressed product, you want something easy to build with, both are valids ways to see a new framework
s
You can always wrap standard Android views in Compose, just use a TextView if it supports multi-line text wrapping. If it doesn't… well, Android SDK has been around for 20 years and still isn't production-ready? That's a bummer.
g
> We don't have the same definition of "prod ready" then, and that's OK. "We" like whole industry except you? There is no promise that Compose is super set of Android Views, it's completely new UI framework from scratch, something could be not there, but the fact that it has a simple solution in 10 lines of code which can be easily converted to generic one for not super rare, but quite specific use case, doesn't make it not ready for production There is not even necessary to wrap TextView, because suggested solution fine, the only fact that it's not in out of the box doesn't make it not ready for prod
n
"We" like whole industry except you?
I'm unsubbing from this thread, thanks for the personal attacks. Coming from a mod, that's a shame. If you weren't so blinded, dismissing every comment not aggreing with you, maybe you'd see that Compose is far from perfect. We (in my company, 20+ Android senior devs with previous Compose experience) struggle often with Compose. Just gotta check the whole number of
// FIXME:
or
HACK:
or just comments lines in the Compose files opposed to the other files. So no, I'm not alone. I like working with Compose in some way (easy animations, declarative), I hate working with Compose in others (sizing, text rendering, performances). We can't all be blinded fanboys you know.
the only fact that it's not in out of the box doesn't make it not ready for prod
You're so blinded you forgot the notion of regression. It was working fine in Android v1 (Views), it's not working fine anymore in Android v2 (Compose). How can you even try to argue with that. WTF.
🙈 1
🤡 1
g
It's not Android v1 and v2 They are differnet, some things work not the same way as on Views, but it's fine, it's not the goal Some things require additional code, but usually are solvable without many problems (as in this case) With all missing parts, it's ready for production and it's better in pretty much everything than views
> maybe you'd see that Compose is far from perfect Nothing is perfect, expect perfection from UI framework is strange. Having Fixme or Hack is normal development process
Don't be a blinded fanboys is totally reasonable. Calling words like "not ready for production" is not reasonable, because it's obviously not true
There is no personal attack; it's an attack on your specific argument, that it's not production-ready, that it's just about a different meaning of what is production-ready between me and you The fact that industry in general migrated to compose and there is pretty much everyone creating new projects only with compose and don't want to return to views means that it's a fact production-ready