Open Dominaezzz opened 3 years ago
Is the same problem present in Android Compose? Why do you believe that behavior we get is not correct?
The reason why I think the behaviour is different is because the docs say otherwise.
It says,
Align the center of the placeholder with the center of the entire line
I don't know if this behaviour is present in Android compose.
Is what it looks like
Looks like it's not present in Android compose.
I am observing this problem in compose multiplatform version 1.7.0-dev1703
for Desktop on Mac OS
@mgroth0 Could you post a reproducer? Both the op's reproducer and the test below seem to work correctly:
fun main() = singleWindowApplication {
val text = buildAnnotatedString {
append("Hello ")
appendInlineContent(inlineContentId, "[myBox]")
append(" inline content")
}
Column {
Text(
text = text,
inlineContent = redSquare(2.em),
style = TextStyle(fontSize = 32.sp),
modifier = Modifier
.padding(8.dp)
.border(Dp.Hairline, color = Color.Black)
)
Text(
text = text,
inlineContent = redSquare(0.5.em),
style = TextStyle(fontSize = 32.sp),
modifier = Modifier
.padding(8.dp)
.border(Dp.Hairline, color = Color.Black)
)
}
}
const val inlineContentId = "inlineContent"
private fun redSquare(size: TextUnit) =
mapOf(
Pair(
inlineContentId,
InlineTextContent(
Placeholder(
width = size,
height = size,
placeholderVerticalAlign = PlaceholderVerticalAlign.Center
)
) {
Box(modifier = Modifier.fillMaxSize().background(color = Color.Red))
}
)
)
I expected
PlaceholderVerticalAlign.Center
to align the centre of the image with the center of the text but it aligns the center of the image with the bottom of the text. For all values ofPlaceholderVerticalAlign.*
, the align of the image is always aligned with the bottom of the text.