Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

fillMaxHeight() inside Row

My question is related to this one: How to achieve this layout in Jetpack Compose

I have this code:

@Composable
fun TestUi() {
    Row {
        Box(
            contentAlignment = Alignment.Center,
            modifier = Modifier
                .background(color = Color.Yellow)
                .fillMaxHeight()
        ) {
            CircularProgressIndicator()
        }
    
        Image(imageVector = vectorResource(id = R.drawable.ic_launcher_background))
    }
}

I expected to get this:

Expected result

But I got this instead:

Actual result

How can I get the Box to fill all the available height without affecting the height of the Row?

I know I could use a ConstraintLayout to solve this, but it seems too much for such a simple use case.

like image 203
Milack27 Avatar asked Sep 01 '25 02:09

Milack27


1 Answers

This worked for me Modifier.height(IntrinsicSize.Min)

@Composable
fun content() {
    return Row(
        modifier = Modifier
            .height(IntrinsicSize.Min)
    ) {
        Box(
            modifier = Modifier
                .width(8.dp)
                .fillMaxHeight()
                .background(Color.Red)
        )
        Column {
            Text("Hello")
            Text("World")
        }
    }
}

source: https://www.rockandnull.com/jetpack-compose-fillmaxheight-fillmaxwidth/

like image 169
Bills Avatar answered Sep 04 '25 07:09

Bills