Chris Fillmore
09/28/2022, 6:08 PMposition: absolute
is in Compose.Chris Fillmore
09/28/2022, 6:09 PMabsolute
removes something from the document flow and positions it relative to its nearest positioned ancestor.
But, for instance, if I have a Compose Box
with its own padding, I can’t use BoxScope.align
the way that CSS positioning allows for top
, left
and suchChris Fillmore
09/28/2022, 6:12 PMBox {
val outerScope = this
Box(
Modifier.padding(24.dp)
) {
Text(
text = "some text",
modifier = with (outerScope) { Modifier.align(Alignment.TopStart) }
)
}
}
hmmChris Fillmore
09/28/2022, 6:12 PMChris Sinco [G]
09/28/2022, 6:26 PMChris Sinco [G]
09/28/2022, 6:30 PMChris Fillmore
09/28/2022, 6:39 PMSurface {
Box(Modifier.padding(24.dp)) {
// the contents of the card: badge, text, button
}
// background image here
}
But then I realized that some elements within the card have CSS positioning like this:
position: absolute;
top: 72px;
left: 24px;
So now my 24.dp padding on my Compose Box is not very helpfulChris Fillmore
09/28/2022, 6:40 PMChris Fillmore
09/28/2022, 6:41 PMChris Fillmore
09/28/2022, 6:42 PMChris Sinco [G]
09/28/2022, 10:34 PMChris Sinco [G]
09/28/2022, 10:34 PMChris Sinco [G]
09/28/2022, 10:40 PMChris Fillmore
09/28/2022, 11:49 PMChris Fillmore
09/28/2022, 11:52 PM