ursus
10/22/2024, 6:26 PMfillMaxWidth()
, say up to 500.dp
?
What maxWidth
used to beZach Klippenstein (he/him) [MOD]
10/22/2024, 6:27 PMAlex Styl
10/22/2024, 6:42 PMZach Klippenstein (he/him) [MOD]
10/22/2024, 6:43 PMursus
10/22/2024, 6:58 PMBox(
modifier = Modifier
.fillMaxWidth()
.widthIn(max = 200.dp)
.aspectRatio(1.94f)
.clickable { onScratchCardClick(item.promotionId) }
) {
like this? doesn't workursus
10/22/2024, 7:03 PMsizeIn
Box(
modifier = Modifier
.fillMaxWidth()
.sizeIn(maxWidth = 50.dp)
.height(100.dp)
.background(Color.Red)
)
still fills all of the widthStylianos Gakis
10/22/2024, 7:05 PMursus
10/22/2024, 7:06 PMursus
10/22/2024, 7:06 PMStylianos Gakis
10/22/2024, 7:07 PMZach Klippenstein (he/him) [MOD]
10/22/2024, 7:13 PMwidthIn
effectively does:
minWidth = requestedMin.coerceAtLeast(incomingMin)
maxWidth = requestedMax.coerceAtMost(incomingMax)
So that the incoming constraints always win.
fillMaxWidth
is effectively:
widthIn(min = incomingMax, max = incomingMax)
So fillMaxWidth().widthIn()
will ignore the widthIn
params in most cases.ursus
10/22/2024, 7:14 PMZach Klippenstein (he/him) [MOD]
10/22/2024, 7:15 PMursus
10/22/2024, 7:15 PMBox(
modifier = Modifier
.width(200.dp)
.height(100.dp)
.clickable { onScratchCardClick(item.promotionId) }
) {
even if I do this, it's still full width for what ever reasonZach Klippenstein (he/him) [MOD]
10/22/2024, 7:15 PMwidth()
also always obeys incoming constraints (it's just widthIn(min = width, max = width)
, so it sounds like you've got incoming constraints that are forcing it to be bigger.ursus
10/22/2024, 7:16 PMZach Klippenstein (he/him) [MOD]
10/22/2024, 7:16 PMursus
10/22/2024, 7:18 PMCard(shape = MaterialTheme.shapes.large, elevation = 6.dp) {
Box(
modifier = Modifier
.sizeIn(maxWidth = 200.dp)
.fillMaxWidth()
.aspectRatio(0.98f)
) {
great
but same code as a item in lazy column, no diceZach Klippenstein (he/him) [MOD]
10/22/2024, 7:21 PMwrapContentWidth()
before width
? You could also use requiredWidth
, but then you lose control over alignment.