Reputation: 682
So I know that when I don't use Modifier.height() is like "WRAP_CONTENT" is set, but what if I want to set the value in height as WRAP_CONTENT. Is there a way to do this?
Already tried InstrinsicSize.Min, InstrinsicSize.Max and 0.dp.
Looking for something like this: Modifier.height(WRAP_CONTENT)
This is just for specific knowledge as I can't find nothing in the documents.
Upvotes: 14
Views: 9133
Reputation: 972
You can actually use it as Modifier.wrapContentWidth() or Modifier.wrapContentHeight() or both as:
Image(
painter = painterResource(id = R.drawable.happy_meal_small),
contentDescription = "",
modifier = Modifier.wrapContentWidth().Modifier.wrapContentHeight()
)
which works as WRAP_CONTENT
Upvotes: 2
Reputation: 364361
You can use the wrapContentHeight
modifier.
For example:
Box(
Modifier.size(50.dp)
.wrapContentHeight(Alignment.CenterVertically)
.height(20.dp)
.background(Color.Blue)
)
In this case the result will be a 50.dp
x 20.dp
blue box centered vertically in a 50.dp
x 50.dp
if wrapContentHeight
did not exist, the blue rectangle would actually be 50.dp
x 50.dp
to satisfy the size set by the modifier.
Upvotes: 13