Fudge

    Fudge

    2 years ago
    How can I place a component under a
    LazyColumnItems
    ? I have no problem placing one above it, e.g.
    Column {
                Text("top")
                LazyColumnItems(items = listOf("1","2","3")) {
                    Text(it)
                }
            }
    But if I try to place it below the
    bottom
    text doesn't appear.
    Column {
                LazyColumnItems(items = listOf("1","2","3")) {
                    Text(it)
                }
                Text("bottom")
            }
    (In my case I also want to attach
    bottom
    to the bottom of the column so I would add
    fillMaxHeight().wrapContentHeight(Alignment.Bottom)
    as well)
    matvei

    matvei

    2 years ago
    LazyColumnItems
    and
    LazyRowItems
    are yet to support wrap content, now they always fill
    Timo Drick

    Timo Drick

    2 years ago
    Do you really want this? Noramlly you use LazyColumnItems when you expect a large number of items (>5) and this will fill the complete screen and than the bottom text is not visible anyways. So maybe you want an other layout? Maybe set the height to Modifier.weight(1f) for the LazyColumnItems element?
    Column {
                LazyColumnItems(modifier = Modifier.weight(1f), items = listOf("1","2","3")) {
                    Text(it)
                }
                Text("bottom")
            }
    Fudge

    Fudge

    2 years ago
    I want the LazyColumnItems to end at the bottom element
    using Modifier.weight() made the list disappear 😢
    Timo Drick

    Timo Drick

    2 years ago
    With my suggestion it will look exactly like this. But when you have not enough items in the list to fill the view there will be a gap between the last element in list and the bottom element.
    Fudge

    Fudge

    2 years ago
    yes that is good
    Timo Drick

    Timo Drick

    2 years ago
    weight(1f)
    Fudge

    Fudge

    2 years ago
    let me try to do it exactly like you showed, sec
    yes that seems to work, I need to figure out why it doesn't work in my app then
    Timo Drick

    Timo Drick

    2 years ago
    This weight(1f) is the same like in the legacy (LinearLayout). So it will fill the rest of available space with the list.
    Fudge

    Fudge

    2 years ago
    Nice it works well now, thank you!