0

I want to do basic view of two Columns in Jetpack Compose where

ColumnA has dynamic height based on some calculations. ColumnB is under ColumnA with fixed height and set for vertical scrolling

However ColumnA is cutting of ColumnB space and it doesn't help to adjust height of ColumnB - it works only if I put fixed dp value, but when it's derived from ColumnA, it doesn't work.

Is there any clever way how to solve this problem?

TLDR: Trying to put two Columns vertically, but Column with dynamic height cut of Column with fixed height.

Column(modifier = Modifier.fillMaxHeight()) {
  // A
  Column()) {
  // some content with dynamic height
  }
  // B with vertical scrolling
  Column(modifier = Modifier.height(1000.dp)) {
  }
}

Thank you

hepepnyt
  • 1
  • 3
  • Would weight work for you? https://stackoverflow.com/questions/58650272/weights-in-jetpack-compose – Ben P. Aug 16 '21 at 18:30

2 Answers2

0

You can instruct your first column to occupy all the space not occupied by the 2nd by using weight(1f)

    Column(modifier = Modifier.weight(1f)) {
        Text(text = "This is the first column")
    }
    // B with vertical scrolling
    Column(modifier = Modifier.fillMaxWidth().height(256.dp)) {
        Text("This is the 2nd column")
    }
Francesc
  • 25,014
  • 10
  • 66
  • 84
0

If the columns are not required to be in contact,

Column(Modifier.fillMaxSize()){
 Column(Modifier.wrapContentHeight().weight(1f, fill = 
 false){

 }
 Column(Modifier.height(/*fixed*/){

 }
}
Richard Onslow Roper
  • 5,477
  • 2
  • 11
  • 42