Вертикально прокручивать компонент измеряли с ограничениями максимальной высоты бесконечности, которые запрещеныAndroid

Форум для тех, кто программирует под Android
Ответить
Anonymous
 Вертикально прокручивать компонент измеряли с ограничениями максимальной высоты бесконечности, которые запрещены

Сообщение Anonymous »

Я использую Composeview внутри моего макета элемента Recyclerview для работы с JetPack Compose. У меня есть странная проблема, когда я открываю экран
ошибка
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.

Я попытался следовать за переполнением этого стека, но он не сработал
main_activity.xml


item_layout.xml








viewholder.kt
class OptionsViewHolder(val binding: ItemLayoutBinding) : Recyclerview.ViewHolder(binding.root) {

private val context = binding.root.context

companion object {
fun from(parent: ViewGroup): OptionsViewHolder {
return OptionsViewHolder(
ItemLayoutBinding.inflate(
LayoutInflater.from(parent.context),
parent,
false
)
)
}
}

fun bindChoice() {
binding.itemComposable.setContent {
BoxWithConstraints {
LazyColumn(
modifier = Modifier
.fillMaxWidth()
.height(this@BoxWithConstraints.maxHeight)
.verticalScroll(rememberScrollState())
) {
items(getOptions()) { option ->
Text(text = option)
}
}
}
}
}

private fun getOptions() = mutableListOf(
context.getString(R.string.monitor),
context.getString(R.string.pressure),
context.getString(R.string.not_sure)
)
}


Подробнее здесь: https://stackoverflow.com/questions/731 ... height-con
Ответить

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

Вернуться в «Android»