How can I align horizontally a particular children...
# compose
p
How can I align horizontally a particular children in a LazyColumn? it worked perfectly using Column, but it doesn't work in LazyColumn because I can't import Modifier.align for each particular item of the list, doesn't exist align import. I'm attaching code in a thread here:
Column:
Copy code
Column(
        modifier = modifier.fillMaxWidth(),
        horizontalAlignment = column.getHorizontalAligment()
    ) {
        for (element in column.childs) {
            ElementComposableFactory(
                element = element,
                onClickAction = onClickAction,
                modifier = Modifier.align(element.getHorizontalAligment())
            )
        }
    }
LazyColumn:
Copy code
LazyColumn(
        modifier = modifier.fillMaxWidth(),
        horizontalAlignment = column.getHorizontalAligment()
    ) {
        items(column.childs) { element ->
            ElementComposableFactory(
                element = element,
                onClickAction = onClickAction,
                modifier = Modifier.align(element.getHorizontalAligment()) <-- compilation error, align doesn't exist for the items of a lazycolumn
            )
        }
    }
z
p
what do you mean?
if adding this modifier, how can I align the child?
the align method still gives compilation error obviously
s
wrapContentWidth takes in an
Alignment.Horizontal
parameter
z
You put that combination of modifiers on the child instead of align
p
wow, it worked! now is aligning the composables correctly! nice
I just have a problem with this Image composable:
Copy code
AsyncImage(
    model = element.getImageRoute(),
    contentDescription = "",
    modifier = modifier.fillMaxWidth(1f)
)
for some reason, the image is not filling the 100% of the width of the lazycolumn
in some images, it is filling a 30-40% and in some cases is working, depending on the image and his proportion I think
always with the fillMaxWidth(1f) set. Not sure what is happening here
with Column worked perfectly, the issue is only when changed Column to LazyColumn