Status Update
Comments
po...@google.com <po...@google.com>
si...@google.com <si...@google.com> #2
Thanks, can you please add information about the Android version/device as well?
ph...@gmail.com <ph...@gmail.com> #3
I can reproduce it both on Emulator Pixel 5 API 31 arm64 version, and on Meizu X8 API 27
so...@google.com <so...@google.com> #5
Siyamed, just FYI that the duplicate bug was closed a while ago with WAI
si...@google.com <si...@google.com> #6
I skimmed over the comments on the ticket.
Working on the include font padding I saw some opportunities to provide kind of tighter bounds API.
As far as I can see at the time we didn't know what is the absolute right solution and mention a lot about different alignments, rtl, ltr etc.
it looks like it is worth to investigate this a little further to see if there is any non-binary solution to it (API, handling cases separately, the concept of tight-er bounds that would not work for Bidi text where each line paragraph is LTR / RTL.)
I changed it to be a feature request.
si...@google.com <si...@google.com>
so...@google.com <so...@google.com> #7
Assigning to myself as this related to the bug I'm working on
so...@google.com <so...@google.com>
an...@gmail.com <an...@gmail.com> #8
ha...@google.com <ha...@google.com>
ut...@gmail.com <ut...@gmail.com> #9
Facing the same issue in one of my production apps.
Compose UI version: 1.4.3
Compose compiler version: 1.4.7
Compose material version: 1.2.0
This happens when I use modifier = Modifier.weight(1f, fill = false)
in my text.
Please try the following code snippet to reproduce the behavior
Row(
horizontalArrangement = Arrangement.spacedBy(
dimensionResource(id = size.sizes.spaceBetween)
),
verticalAlignment = Alignment.CenterVertically,
modifier = modifier.clickable(
interactionSource = interactionSource,
indication = null,
role = Role.Button
) {
onClick()
}
) {
Text(
text = "this is a very loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong text",
style = TextStyle(
color = theme.textColor,
fontSize = dimenToSp(size.sizes.fontSize),
lineHeight = dimenToSp(size.sizes.lineHeight),
textDecoration = decoration,
fontWeight = if (isBold) FontWeight.Bold else FontWeight.Normal,
textAlign = multilineTextAlign
),
modifier = Modifier.weight(1f, fill = false) // <--- The issue happens when I apply this modifier
)
Icon(
painter = <Some icon here>,
contentDescription = "",
tint = theme.iconColor,
modifier = Modifier.size(
dimensionResource(id = size.sizes.iconSizing) * getSystemFontScale()
)
)
}
ja...@google.com <ja...@google.com> #10
ph...@gmail.com <ph...@gmail.com> #11
You can use
se...@google.com <se...@google.com> #14
Behavior since Compose 1.0. This is ported diligently during Modifiers port
se...@google.com <se...@google.com> #15
There are two cases:
- maxIntrinsicWidth <= constraints.maxWidth. The BasicText is sized to the maxIntrinsicWidth
- maxIntrinsicWidth > constraints.maxWidth (multiline). The BasicText is sized to constraints.maxWidth.
Changing this is a major breaking behavior modification from Compose 1.0.
se...@google.com <se...@google.com> #16
(since public - just doing triage and adding debug notes right now)
si...@google.com <si...@google.com> #17
@seanmcq not sure if you saw the prototype mentioned in
Even if it is not in the prototype, I believed that this could be a new API. (there were multiple tight text idea, one of them for vertical, one of them for horizontal where the horizontal one is the issue in this ticket)
se...@google.com <se...@google.com> #18
Nice!
so...@google.com <so...@google.com> #19
For the note, we did work in MultiParagraph so it accepts Constraints object rather than simply maxWidth, which is pre-requisite for this change. I think that wrapping behaviour should have been a default behaviour. This is pretty much what we do in Row and Column for example, because expanding from wrapping to filling is easy compared to the other way around.
Now, as per
se...@google.com <se...@google.com> #20
Picking this one up as it's next.
se...@google.com <se...@google.com>
al...@dif.tech <al...@dif.tech> #21
[Deleted User] <[Deleted User]> #22
ph...@gmail.com <ph...@gmail.com> #23
ar...@gmail.com <ar...@gmail.com> #24
pa...@gmail.com <pa...@gmail.com> #25
da...@gmail.com <da...@gmail.com> #26
br...@mindera.com <br...@mindera.com> #27
ya...@gmail.com <ya...@gmail.com> #28
ta...@gmail.com <ta...@gmail.com> #29
Any news about this?
ti...@edreamsodigeo.com <ti...@edreamsodigeo.com> #30
si...@sentbe.com <si...@sentbe.com> #31
I still waiting for update.
va...@google.com <va...@google.com> #32
A workaround that doesn't rely on subcomposition:
@Preview(widthDp = 300, heightDp = 400)
@Preview(widthDp = 400, heightDp = 400)
@Preview(widthDp = 500, heightDp = 400)
@Preview(widthDp = 600, heightDp = 400)
@Preview(widthDp = 700, heightDp = 400)
@Preview(widthDp = 800, heightDp = 400)
@Composable
private fun TightWrapText() {
var textLayoutResult: TextLayoutResult? by remember { mutableStateOf(null) }
BasicText(
text = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.",
modifier = Modifier
.background(Color.Blue)
.layout { measurable, constraints ->
val placeable = measurable.measure(constraints)
val newTextLayoutResult = textLayoutResult!!
if (newTextLayoutResult.lineCount == 0) {
// Default behavior if there is no text
layout(placeable.width, placeable.height) {
placeable.placeRelative(0, 0)
}
} else {
val minX = (0 until newTextLayoutResult.lineCount).minOf(newTextLayoutResult::getLineLeft)
val maxX = (0 until newTextLayoutResult.lineCount).maxOf(newTextLayoutResult::getLineRight)
layout(ceil(maxX - minX).toInt(), placeable.height) {
placeable.place(-floor(minX).toInt(), 0)
}
}
},
onTextLayout = {
textLayoutResult = it
}
)
}
ch...@gmail.com <ch...@gmail.com> #33
Curios if anything is in the works?
hu...@gmail.com <hu...@gmail.com> #34
Used workaround for my case (centered left-aligned multiline text):
Column(
horizontalAlignment = Alignment.Start,
verticalArrangement = Arrangement.Center,
modifier = Modifier
.wrapContentWidth()
.padding(10.dp)
.weight(1f)
) {
text.split('\n').forEach{
Text(
text = it.trim(),
fontSize = 6.em,
modifier = Modifier
.wrapContentWidth()
)
}
}
Description
I need to draw a background/border for a multiline text
But width of this view is equal scope max constraint instead of width of the widest line.
I'm attaching an image how I expect it to look like and how it actually looks like