android-jetpack-compose-layout
Fill height for child in Row
You have to apply Modifier.height(IntrinsicSize.Min) to the Row and the fillMaxHeight() modifier to the 2nd Box. Something like: Card(shape = RoundedCornerShape(8.dp)) { Row( modifier = Modifier.height(IntrinsicSize.Min) //Intrinsic measurement ) { Box( Modifier .background(Color.Yellow) .weight(1f) ) { //Box(Modifier.height(50.dp)) } Box( Modifier .width(20.dp) .fillMaxHeight() //<— fill max height .background(Color.Green) ) { //…….. } } } As explained … Read more
Create Vertical Divider Jetpack Compose
You can use the Divider composable with the width(xx.dp) modifier applying an intrinsic measurements to its parent container. Something like: Row(Modifier .height(IntrinsicSize.Min) //intrinsic measurements .fillMaxWidth() .background(Color.Yellow) ) { Text(“First Text”) Divider( color = Color.Red, modifier = Modifier .fillMaxHeight() //fill the max height .width(1.dp) ) Text(“Second text”) } As explained in the doc: The Row composable’s … Read more
Weights in Jetpack compose
You can use the Modifier.weight Something like: Row() { Column( Modifier.weight(1f).background(Blue) ){ Text(text = “Weight = 1”, color = Color.White) } Column( Modifier.weight(2f).background(Yellow) ) { Text(text = “Weight = 2”) } }
Jetpack Compose – Column – Gravity center
You can use these parameters: horizontalAlignment = the horizontal gravity of the layout’s children. verticalArrangement= the vertical arrangement of the layout’s children Something like: Column( modifier = Modifier.fillMaxSize(), verticalArrangement = Arrangement.Center, horizontalAlignment = Alignment.CenterHorizontally ) { Text( text = “First item”, modifier = Modifier.padding(16.dp) ) Text( text = “Second item”, modifier = Modifier.padding(16.dp) ) Text( … Read more