Does `fillMaxSize` not work if the container is sc...
# compose
f
Does
fillMaxSize
not work if the container is scrollable?
d
Haha, probably. Since one of the dimensions would be infinity,
f
I was hoping that it can still take the screen size into account
d
Ah, you can use Modifier.aspectRatio() maybe.
Or a top level BoxWithConstraints
f
Nevermind, I solved my problem
I figured out that I can add additional modifiers
and I only need that modifier in landscape mode
but thank you for your help
c
What modifier did you use? I also have a similar question where I basically want something to be the entire screen height, but it's the first item in a lazyColumn
a
@Colton Idle Use the modifier fillParentMaxSize() Example:
Copy code
LazyColumn() {
            item{                                  Box(Modifier.background(Color.Yellow).fillParentMaxSize())
            }
}
This sets the first item to be the size of the parent, which is the lazy column.
c
Oh nice!
l
Having the same kind of problem here but I cannot use fillParentMaxSize() because I'm using a regular row and not a LazyRow. How would you guys solve this? Trying to just put a divider between two other composable. 😅 For instance:
Copy code
Row(
    modifier = Modifier.verticalScroll(rememberScrollState())
) {
    Text(text = "One")
    Box(
        modifier = Modifier
            .fillMaxHeight()
            .width(1.dp)
            .background(Color.Red)
    )
    Text(text = "Two")
}
a
@Lorenzo Benevento That only works in Lazy item scopes. Have you tried using
Divider()
as the Composable?
Also what are you aiming to achieve, to have the divider take up the whole screen between the two texts?
l
Divider is just a fancy box basically, also I need a vertical divider,
Divider()
only works as an horizontal divider. Probably a bit less then the height of the row but yeah. I could use a constant height, but if the other two composable change dimensions for some reasons it won't scale!
c
@Lorenzo Benevento do you have a drawing of how this should look? I'm... Confused
a
I played around with your example, and the divider disappears as soon as the verticalScroll modifier is added. Why not simply wrap your row inside a lazy column if the content is dynamic in size?
l
@Colton Idle I will as soon as I can! @Anthony I could use a LazyRow()/wrapping it in a LazyColumn() even though the content is not really dynamic as far as the number of elements is concerned! How bad would that be in terms of performance in your opinion? I think not much given the nature of Compose but it's just a guess.
@Colton Idle This is what I'm trying to achieve. In the screen it was achieved using a fixed height for the divider but this means it won't scale at all!
210 Views