Given some type of container how would I draw only...
# compose
c
Given some type of container how would I draw only the bottom half of a piece of text within the given container? Such that the top of the half of text (aka the middle vertical point if the text was fully drawn) touches the top of the parent container and the bottom touches the bottom of the parent container?
I've tried shapes, offsets, and graphic layer. I keep ending up with the top half of the text cut off and offset when I need the bottom
n
Sounds like you might need to use
Modifier.clip
with a rect shape that is half of the size of the text composable. Do you have a screenshot or a mock of what you are trying to build?
a
This should work:
Copy code
Text(text = "Text", modifier = Modifier.clipToBounds().layout { measurable, _ ->
    val placeable = measurable.measure(Constraints())
    val halfHeight = placeable.height / 2
    layout(placeable.width, halfHeight) {
        placeable.place(0, -halfHeight)
    }
})
c
This worked perfectly! Thanks!