Hey all, I am calling a composable with lazy colum...
# compose
b
Hey all, I am calling a composable with lazy column inside of another compsable (homescreen) and getting this error. The problem I am running into is that I can’t have a vertical scrollState with a lazy column? What would be this fix?
java.lang.IllegalStateException: Vertically scrollable component was measured with an infinity maximum height constraints, which is disallowed. One of the common reasons is nesting layouts like LazyColumn and Column(Modifier.verticalScroll()). If you want to add a header before the list of items please add a header as a separate item() before the main items() inside the LazyColumn scope. There are could be other reasons for this to happen: your ComposeView was added into a LinearLayout with some weight, you applied Modifier.wrapContentSize(unbounded = true) or wrote a custom layout. Please try to remove the source of infinite constraints in the hierarchy above the scrolling container.
how to put a LazyColumn inside Column(Modifier.verticalScroll())
a
Used to be the case that nesting these two scrollables was not allowed, albeit the error message was a different one. Maybe this changed with RC01, but in 1.0.5 and up until at least 1.1.0-beta03 nesting a LazyColumn inside of a scrollable container was not allowed.
b
so no solution with this?? this sucks!!!
a
You should rethink how you nest your Composables. If you think Compose sucks because of these little starting issues (compose got out of beta just a few months ago), honestly just go back to xml 👋
b
What can I put these in?
I tried a Column but didn’t work
a
Put it inside an
item()
block
👍 1
b
I added a sticky header but the content scrolls under it. The logo is a svg, do I need to add a background or something?
a
do I need to add a background or something
Yup, that would “fix” it.
b
I guess that wouldn’t be the right way?
it still shows on top
a
What do you mean? A sticky header is supposed to show on top of the content, isn’t it? Do you want it to scroll with the content instead?
b
No, I want the logo to stick just like this, but the content to disappear when I scroll to the top instead of the image below
a
Adding a background didn’t achieve that? Also, seems to me that you want a TopAppBar basically. You could try Scaffold to have a TopAppBar and then the
LazyColumn
in its content.
b
I’ll try that!
At the end of the list, the card doesn’t fully show. Is there something I can do to make sure the last card on the list shows fully?
a
contentPadding
argument on
LazyColumn
would solve that.
c
Or you can put your LazyColumn in a col. Example: Col{ TopAppBar LazyColumn(Modifier.weight(1f)) BottomTabBar } and your content wouldn't draw under the bottomBar
I think a scaffold also has that behavior out of the box