Мне нужно реализовать два LazyComuns на одном экране, один под другим (при нажатии на элемент в верхнем списке он перейдет в нижний и наоборот), при этом экран должен иметь 1 общий прокрутки, а не вложен в каждый из LazyColumns. Если я оберну два LazyColumns в Column с модификатором = Modifier.verticalScroll(rememberScrollState()) - я получу ошибку:
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.
Макет выглядит так:
@Composable
fun AppListLayout(
viewModel: AppListViewModel = viewModel()
) {
Column(
modifier = Modifier
.fillMaxWidth()
.verticalScroll(rememberScrollState())
) {
ApplicationList(title = ...) // first app lsit
ApplicationList(title = ...) // second app list
}
}
@Composable
fun ApplicationList(
title: String,
appList: List
) {
Card {
LazyColumn {
items(
items = appList,
key = { it }
) { app ->
AppListItem(app)
}
}
}
}
Подробнее здесь: https://stackoverflow.com/questions/785 ... mon-scroll
Два LazyColumn на одном экране с общей прокруткой ⇐ Android
Форум для тех, кто программирует под Android
-
Anonymous
1716468405
Anonymous
Мне нужно реализовать два LazyComuns на одном экране, один под другим (при нажатии на элемент в верхнем списке он перейдет в нижний и наоборот), при этом экран должен иметь 1 общий прокрутки, а не вложен в каждый из LazyColumns. Если я оберну два LazyColumns в Column с модификатором = Modifier.verticalScroll(rememberScrollState()) - я получу ошибку:
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.
Макет выглядит так:
@Composable
fun AppListLayout(
viewModel: AppListViewModel = viewModel()
) {
Column(
modifier = Modifier
.fillMaxWidth()
.verticalScroll(rememberScrollState())
) {
ApplicationList(title = ...) // first app lsit
ApplicationList(title = ...) // second app list
}
}
@Composable
fun ApplicationList(
title: String,
appList: List
) {
Card {
LazyColumn {
items(
items = appList,
key = { it }
) { app ->
AppListItem(app)
}
}
}
}
Подробнее здесь: [url]https://stackoverflow.com/questions/78523222/two-lazycolumn-on-one-screen-with-common-scroll[/url]
Ответить
1 сообщение
• Страница 1 из 1
Перейти
- Кемерово-IT
- ↳ Javascript
- ↳ C#
- ↳ JAVA
- ↳ Elasticsearch aggregation
- ↳ Python
- ↳ Php
- ↳ Android
- ↳ Html
- ↳ Jquery
- ↳ C++
- ↳ IOS
- ↳ CSS
- ↳ Excel
- ↳ Linux
- ↳ Apache
- ↳ MySql
- Детский мир
- Для души
- ↳ Музыкальные инструменты даром
- ↳ Печатная продукция даром
- Внешняя красота и здоровье
- ↳ Одежда и обувь для взрослых даром
- ↳ Товары для здоровья
- ↳ Физкультура и спорт
- Техника - даром!
- ↳ Автомобилистам
- ↳ Компьютерная техника
- ↳ Плиты: газовые и электрические
- ↳ Холодильники
- ↳ Стиральные машины
- ↳ Телевизоры
- ↳ Телефоны, смартфоны, плашеты
- ↳ Швейные машинки
- ↳ Прочая электроника и техника
- ↳ Фототехника
- Ремонт и интерьер
- ↳ Стройматериалы, инструмент
- ↳ Мебель и предметы интерьера даром
- ↳ Cантехника
- Другие темы
- ↳ Разное даром
- ↳ Давай меняться!
- ↳ Отдам\возьму за копеечку
- ↳ Работа и подработка в Кемерове
- ↳ Давай с тобой поговорим...
Мобильная версия