- Вызов NavHost для экрана с Lazy вызывает небольшое зависание и перезапуск приложения.
- После перезапуска приложение при вызове NavHost для того же экрана вызывает сбой с системным сообщением «приложение продолжает останавливаться»
в журнале нет фатальных ошибок
Также я пытался отправить любые случайные простые данные для локальной сборки Lazy. Составные (например, список из 1–10 и текстовые элементы со значениями)
Все работает, когда я использую простой столбец, строки или 1 элемент
Это мой текущий код для этого элемента. Но это также не сработает, если я использую Any Text() вместо элемента Content.
@Composable
fun ContentGrid(
content: List,
) {
LazyColumn {
items(content) {
ContentElement(item = it)
}
}
}
@Composable
fun ContentElement(item: Item) {
Card(
modifier = Modifier
.fillMaxWidth(0.4f)
.fillMaxHeight(0.3f)
.clip(RoundedCornerShape(10))
.clickable(enabled = true, onClick = { }),
colors = CardDefaults.cardColors(
containerColor = Color(200, 200, 238, 226),
contentColor = Color.Black,
)
) {
Column(
modifier = Modifier.padding(5.dp),
horizontalAlignment = Alignment.CenterHorizontally,
verticalArrangement = Arrangement.SpaceBetween,
) {
Image(
painter = rememberAsyncImagePainter(item.url),
contentDescription = null,
contentScale = ContentScale.FillWidth,
modifier = Modifier
.size(100.dp),
)
/* AsyncImage(
model = item.url,
contentDescription = item.title,
modifier = Modifier
.size(200.dp, 200.dp)
.clip(RoundedCornerShape(10)),
contentScale = ContentScale.FillWidth),*/
Column(
Modifier.fillMaxWidth(),
horizontalAlignment = Alignment.Start,
) {
Spacer(Modifier.height(10.dp))
Text(item.title, fontSize = 15.sp, fontWeight = FontWeight.Bold)
Spacer(Modifier.height(10.dp))
Text(item.price, fontSize = 20.sp, fontWeight = FontWeight.Bold)
}
}
}
}
Это исключение, которое приводит к сбою:
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. P l e a s e t r y t o r e m o v e t h e s o u r c e o f i n f i n i t e c o n s t r a i n t s i n t h e h i e r a r c h y a b o v e t h e s c r o l l i n g c o n t a i n e r . < b r / > a t a n d r o i d x . c o m p o s e . f o u n d a t i o n . C h e c k S c r o l l a b l e C o n t a i n e r C o n s t r a i n t s K t . c h e c k S c r o l l a b l e C o n t a i n e r C o n s t r a i n t s - K 4 0 F 9 x A ( C h e c k S c r o l l a b l e C o n t a i n e r C o n s t r a i n t s . k t : 3 5 ) < b r / > a t a n d r o i d x . c o m p o s e . f o u n d a t i o n . l a z y . L a z y L i s t K t $ r e m e m b e r L a z y L i s t M e a s u r e P o l i c y $ 1 $ 1 . i n v o k e - 0 k L q B q w ( L a z y L i s t . k t : 1 8 7 ) < b r / > a t a n d r o i d x . c o m p o s e . f o u n d a t i o n . l a z y . L a z y L i s t K t $ r e m e m b e r L a z y L i s t M e a s u r e P o l i c y $ 1 $ 1 . i n v o k e ( L a z y L i s t . k t : 1 8 3 ) < b r / > a t a n d r o i d x . c o m p o s e . f o u n d a t i o n . l a z y . l a y o u t . L a z y L a y o u t K t $ L a z y L a y o u t $ 3 $ 2 $ 1 . i n v o k e - 0 k L q B q w ( L a z y L a y o u t . k t : 1 1 9 ) < b r / > a t a n d r o i d x . c o m p o s e . f o u n d a t i o n . l a z y . l a y o u t . L a z y L a y o u t K t $ L a z y L a y o u t $ 3 $ 2 $ 1 . i n v o k e ( L a z y L a y o u t . k t : 1 1 2 ) < b r / > a t a n d r o i d x . c o m p o s e . u i . l a y o u t . L a y o u t N o d e S u b c o m p o s i t i o n s S t a t e $ c r e a t e M e a s u r e P o l i c y $ 1 . m e a s u r e - 3 p 2 s 8 0 s ( S u b c o m p o s e L a y o u t . k t : 7 2 5 ) < b r / > a t a n d r o i d x . c o m p o s e . u i . n o d e . I n n e r N o d e C o o r d i n a t o r . m e a s u r e - B R T r y o 0 ( I n n e r N o d e C o o r d i n a t o r . k t : 1 3 5 ) < b r / > a t a n d r o i d x . c o m p o s e . u i . g r a p h i c s . S i m p l e G r a p h i c s L a y e r M o d i f i e r . m e a s u r e - 3 p 2 s 8 0 s ( G r a p h i c s L a y e r M o d i f i e r . k t : 6 4 6 ) < b r / > a t a n d r o i d x . c o m p o s e . u i . n o d e . L a y o u t M o d i f i e r N o d e C o o r d i n a t o r . m e a s u r e - B R T r y o 0 ( L a y o u t M o d i f i e r N o d e C o o r d i n a t o r . k t : 1 8 8 ) < b r / > a t a n d r o i d x . c o m p o s e . u i . n o d e . L a y o u t N o d e L a y o u t D e l e g a t e $ p e r f o r m M e a s u r e B l o c k $ 1 . i n v o k e ( L a y o u t N o d e L a y o u t D e l e g a t e . k t : 3 1 6 ) < b r / > a t a n d r o i d x . c o m p o s e . u i . n o d e . L a y o u t N o d e L a y o u t D e l e g a t e $ p e r f o r m M e a s u r e B l o c k $ 1 . i n v o k e ( L a y o u t N o d e L a y o u t D e l e g a t e . k t : 3 1 5 ) < b r / > a t a n d r o i d x . c o m p o s e . r u n t i m e . s n a p s h o t s . S n a p s h o t $ C o m p a n i o n . o b s e r v e ( S n a p s h o t . k t : 5 0 3 ) < b r / > a t a n d r o i d x . c o m p o s e . r u n t i m e . s n a p s h o t s . S n a p s h o t S t a t e O b s e r v e r $ O b s e r v e d S c o p e M a p . o b s e r v e ( S n a p s h o t S t a t e O b s e r v e r . k t : 5 0 2 ) < b r / > a t a n d r o i d x . c o m p o s e . r u n t i m e . s n a p s h o t s . S n a p s h o t S t a t e O b s e r v e r . o b s e r v e R e a d s ( S n a p s h o t S t a t e O b s e r v e r . k t : 2 5 8 ) < b r / > a t a n d r o i d x . c o m p o s e . u i . n o d e . O w n e r S n a p s h o t O b s e r v e r . o b s e r v e R e a d s $ u i _ r e l e a s e ( O w n e r S n a p s h o t O b s e r v e r . k t : 1 3 3 ) < b r / > a t a n d r o i d x . c o m p o s e . u i . n o d e . O w n e r S n a p s h o t O b s e r v e r . o b s e r v e M e a s u r e S n a p s h o t R e a d s $ u i _ r e l e a s e ( O w n e r S n a p s h o t O b s e r v e r . k t : 1 1 3 ) < b r / > a t a n d r o i d x . c o m p o s e . u i . n o d e . L a y o u t N o d e L a y o u t D e l e g a t e . p e r f o r m M e a s u r e - B R T r y o 0 ( L a y o u t N o d e L a y o u t D e l e g a t e . k t : 1 7 7 5 ) < b r / > a t a n d r o i d x . c o m p o s e . u i . n o d e . L a y o u t N o d e L a y o u t D e l e g a t e . a c c e s s $ p e r f o r m M e a s u r e - B R T r y o 0 ( L a y o u t N o d e L a y o u t D e l e g a t e . k t : 4 0 ) < b r / > a t a n d r o i d x . c o m p o s e . u i . n o d e . L a y o u t N o d e L a y o u t D e l e g a t e $ M e a s u r e P a s s D e l e g a t e . r e m e a s u r e - B R T r y o 0 ( L a y o u t N o d e L a y o u t D e l e g a t e . k t : 6 9 6 ) < b r / > a t a n d r o i d x . c o m p o s e . u i . n o d e . L a y o u t N o d e L a y o u t D e l e g a t e $ M e a s u r e P a s s D e l e g a t e . m e a s u r e - B R T r y o 0 ( L a y o u t N o d e L a y o u t D e l e g a t e . k t : 6 7 2 ) < b r / > a t a n d r o i d x . c o m p o s e . a n i m a t i o n . A n i m a t e d E n t e r E x i t M e a s u r e P o l i c y . m e a s u r e - 3 p 2 s 8 0 s ( A n i m a t e d V i s i b i l i t y . k t : 8 1 2 ) < b r / > a t a n d r o i d x . c o m p o s e . u i . n o d e . I n n e r N o d e C o o r d i n a t o r . m e a s u r e - B R T r y o 0 ( I n n e r N o d e C o o r d i n a t o r . k t : 1 3 5 ) < b r / > a t a n d r o i d x . c o m p o s e . a n i m a t i o n . E n t e r E x i t T r a n s i t i o n M o d i f i e r N o d e . m e a s u r e - 3 p 2 s 8 0 s ( E n t e r E x i t T r a n s i t i o n . k t : 1 1 7 3 ) < b r / > a t a n d r o i d x . c o m p o s e . u i . n o d e . L a y o u t M o d i f i e r N o d e C o o r d i n a t o r . m e a s u r e - B R T r y o 0 ( L a y o u t M o d i f i e r N o d e C o o r d i n a t o r . k t : 1 8 8 ) < b r / > a t a n d r o i d x . c o m p o s e . u i . g r a p h i c s . B l o c k G r a p h i c s L a y e r M o d i f i e r . m e a s u r e - 3 p 2 s 8 0 s ( G r a p h i c s L a y e r M o d i f i e r . k t : 5 7 8 ) < b r / > a t a n d r o i d x . c o m p o s e . u i . n o d e . L a y o u t M o d i f i e r N o d e C o o r d i n a t o r . m e a s u r e - B R T r y o 0 ( L a y o u t M o d i f i e r N o d e C o o r d i n a t o r . k t : 1 8 8 ) < b r / > a t a n d r o i d x . c o m p o s e . a n i m a t i o n . A n i m a t e d C o n t e n t K t $ A n i m a t e d C o n t e n t $ 6 $ 1 $ 1 $ 1 . i n v o k e - 3 p 2 s 8 0 s ( A n i m a t e d C o n t e n t . k t : 7 8 1 ) < b r / > a t a n d r o i d x . c o m p o s e . a n i m a t i o n . A n i m a t e d C o n t e n t K t $ A n i m a t e d C o n t e n t $ 6 $ 1 $ 1 $ 1 . i n v o k e ( A n i m a t e d C o n t e n t . k t : 7 8 0 ) < b r / > a t a n d r o i d x . c o m p o s e . u i . l a y o u t . L a y o u t M o d i f i e r I m p l . m e a s u r e - 3 p 2 s 8 0 s ( L a y o u t M o d i f i e r . k t : 2 9 4 ) < b r / > a t a n d r o i d x . c o m p o s e . u i . n o d e . L a y o u t M o d i f i e r N o d e C o o r d i n a t o r . m e a s u r e - B R T r y o 0 ( L a y o u t M o d i f i e r N o d e C o o r d i n a t o r . k t : 1 8 8 ) < b r / > a t a n d r o i d x . c o m p o s e . u i . n o d e . L a y o u t N o d e L a y o u t D e l e g a t e $ p e r f o r m M e a s u r e B l o c k $ 1 . i n v o k e ( L a y o u t N o d e L a y o u t D e l e g a t e . k t : 3 1 6 ) < b r / > a t a n d r o i d x . c o m p o s e . u i . n o d e . L a y o u t N o d e L a y o u t D e l e g a t e $ p e r f o r m M e a s u r e B l o c k $ 1 . i n v o k e ( L a y o u t N o d e L a y o u t D e l e g a t e . k t : 3 1 5 ) < b r / > a t a n d r o i d x . c o m p o s e . r u n t i m e . s n a p s h o t s . S n a p s h o t $ C o m p a n i o n . o b s e r v e ( S n a p s h o t . k t : 5 0 3 ) < b r / > a t a n d r o i d x . c o m p o s e . r u n t i m e . s n a p s h o t s . S n a p s h o t S t a t e O b s e r v e r $ O b s e r v e d S c o p e M a p . o b s e r v e ( S n a p s h o t S t a t e O b s e r v e r . k t : 5 0 2 ) < b r / > a t a n d r o i d x . c o m p o s e . r u n t i m e . s n a p s h o t s . S n a p s h o t S t a t e O b s e r v e r . o b s e r v e R e a d s ( S n a p s h o t S t a t e O b s e r v e r . k t : 2 5 8 ) < b r / > a t a n d r o i d x . c o m p o s e . u i . n o d e . O w n e r S n a p s h o t O b s e r v e r . o b s e r v e R e a d s $ u i _ r e l e a s e ( O w n e r S n a p s h o t O b s e r v e r . k t : 1 3 3 ) < b r / > a t a n d r o i d x . c o m p o s e . u i . n o d e . O w n e r S n a p s h o t O b s e r v e r . o b s e r v e M e a s u r e S n a p s h o t R e a d s $ u i _ r e l e a s e ( O w n e r S n a p s h o t O b s e r v e r . k t : 1 1 3 ) < b r / > a t a n d r o i d x . c o m p o s e . u i . n o d e . L a y o u t N o d e L a y o u t D e l e g a t e . p e r f o r m M e a s u r e - B R T r y o 0 ( L a y o u t N o d e L a y o u t D e l e g a t e . k t : 1 7 7 5 ) < b r / > a t a n d r o i d x . c o m p o s e . u i . n o d e . L a y o u t N o d e L a y o u t D e l e g a t e . a c c e s s $ p e r f o r m M e a s u r e - B R T r y o 0 ( L a y o u t N o d e L a y o u t D e l e g a t e . k t : 4 0 ) < b r / > a t a n d r o i d x . c o m p o s e . u i . n o d e . L a y o u t N o d e L a y o u t D e l e g a t e $ M e a s u r e P a s s D e l e g a t e . r e m e a s u r e - B R T r y o 0 ( L a y o u t N o d e L a y o u t D e l e g a t e . k t : 6 9 6 ) < b r / > a t a n d r o i d x . c o m p o s e . u i . n o d e . L a y o u t N o d e L a y o u t D e l e g a t e $ M e a s u r e P a s s D e l e g a t e . m e a s u r e - B R T r y o 0 ( L a y o u t N o d e L a y o u t D e l e g a t e . k t : 6 7 2 ) < b r / > a t a n d r o i d x . c o m p o s e . a n i m a t i on.AnimatedContentMeasurePolicy.measure-3p2s80s(AnimatedContent.kt:837)
at androidx.compose.ui.node.InnerNodeCoordinator.measure-BRTryo0(InnerNodeCoordinator.kt:135)
at androidx.compose.ui.node.LayoutNodeLayoutDelegate$performMeasureBlock$1.invoke(LayoutNodeLayoutDelegate.kt:316)
at androidx.compose.ui.node.LayoutNodeLayoutDelegate$performMeasureBlock$1.invoke(LayoutNodeLayoutDelegate.kt:315)
at androidx.compose.runtime.snapshots.Snapshot$Companion.observe(Snapshot.kt:2441)
at androidx.compose.runtime.snapshots.SnapshotStateObserver$ObservedScopeMap.observe(SnapshotStateObserver.kt:502)
at androidx.compose.runtime.snapshots.SnapshotStateObserver.observeReads(SnapshotStateObserver.kt:258)
at androidx.compose.ui.node.OwnerSnapshotObserver.observeReads$ui_release(OwnerSnapshotObserver.kt:133)
at androidx.compose.ui.node.OwnerSnapshotObserver.observeMeasureSnapshotReads$ui_release(OwnerSnapshotObserver.kt:113)
at androidx.compose.ui.node.LayoutNodeLayoutDelegate.performMeasure-BRTryo0(LayoutNodeLayoutDelegate.kt:1775)
at androidx.compose.ui.node.LayoutNodeLayoutDelegate.access$performMeasure-BRTryo0(LayoutNodeLayoutDelegate.kt:40)
at androidx.compose.ui.node.LayoutNodeLayoutDelegate$MeasurePassDelegate.remeasure-BRTryo0(LayoutNodeLayoutDelegate.kt:696)
at androidx.compose.ui.node.LayoutNode.remeasure-_Sx5XlM$ui_release(LayoutNode.kt:1221)
at androidx.compose.ui.node.LayoutNode.remeasure-_Sx5XlM$ui_release$default(LayoutNode.kt:1212)
at androidx.compose.ui.node.MeasureAndLayoutDelegate.doRemeasure-sdFAvZA(MeasureAndLayoutDelegate.kt:369)
at androidx.compose.ui.node.MeasureAndLayoutDelegate.remeasureAndRelayoutIfNeeded(MeasureAndLayoutDelegate.kt:566)
at androidx.compose.ui.node.MeasureAndLayoutDelegate.remeasureAndRelayoutIfNeeded$default(MeasureAndLayoutDelegate.kt:534)
at androidx.compose.ui.node.MeasureAndLayoutDelegate.measureAndLayout(MeasureAndLayoutDelegate.kt:390)
at androidx.compose.ui.platform.AndroidComposeView.measureAndLayout(AndroidComposeView.android.kt:1273)
at androidx.compose.ui.node.Owner.measureAndLayout$default(Owner.kt:248)
at androidx.compose.ui.platform.AndroidComposeView.dispatchDraw(AndroidComposeView.android.kt:1555)
at android.view.View.draw(View.java:24845)
at android.view.View.updateDisplayListIfDirty(View.java:23692)
at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:4521)
at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:4494)
at android.view.View.updateDisplayListIfDirty(View.java:23646)
at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:4521)
at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:4494)
at android.view.View.updateDisplayListIfDirty(View.java:23646)
at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:4521)
at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:4494)
at android.view.View.updateDisplayListIfDirty(View.java:23646)
at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:4521)
at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:4494)
at android.view.View.updateDisplayListIfDirty(View.java:23646)
at android.view.ThreadedRenderer.updateViewTreeDisplayList(ThreadedRenderer.java:694)
at android.view.ThreadedRenderer.updateRootDisplayList(ThreadedRenderer.java:700)
at android.view.ThreadedRenderer.draw(ThreadedRenderer.java:798)
at android.view.ViewRootImpl.draw(ViewRootImpl.java:5659)
at android.view.ViewRootImpl.performDraw(ViewRootImpl.java:5312)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:4303)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:2917)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:10324)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:1406)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:1415)
at android.view.Choreographer.doCallbacks(Choreographer.java:1015)
at android.view.Choreographer.doFrame(Choreographer.java:945)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:1389)
at android.os.Handler.handleCallback(Handler.java:959)
at android.os.Handler.dispatchMessage(Handler.java:100)
at android.os.Looper.loopOnce(Looper.java:232)
at android.os.Looper.loop(Looper.java:317)
at android.app.ActivityThread.main(ActivityThread.java:8705)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:580)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:886)
Подробнее здесь: https://stackoverflow.com/questions/790 ... th-an-infi
Мобильная версия