本文介绍了jetpack撰写java.lang.IllegalStateException:开始/结束不平衡的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这段代码会导致崩溃:
我使用撰写版本1.0.0-alpha06
im using compose version 1.0.0-alpha06
有人可以帮助我吗?谢谢
can someone help me? thanks
@Composable
@Preview
private fun Image1() {
Box(modifier = Modifier.fillMaxWidth().wrapContentHeight()) {
Image(
asset = imageResource(id = R.mipmap.fit_static_image_1),
contentScale = ContentScale.FillWidth,
)
Column(Modifier.padding(start = 16.dp, end = 16.dp).align(Alignment.CenterStart), horizontalAlignment = Alignment.Start) {
Text(
color = getColor(id = R.color.white),
fontWeight = FontWeight.Bold,
fontSize = TextUnit.Sp(18),
text = dicString(id = R.string.fit_static_image_1_title),
textAlign = TextAlign.Start
)
Text(
text = dicString(id = R.string.fit_static_image_1_description),
color = getColor(id = R.color.white),
fontSize = TextUnit.Sp(14),
modifier = Modifier.padding(top = 4.dp),
textAlign = TextAlign.Start
)
}
}
}
推荐答案
我使用了记住{} 错误,我试图在 dicString 函数中使用它来记住获得的字符串.这引起了问题.我通过将资源ID添加到Remember函数作为参数来解决此问题.记住(id){}
i was using remember { } wrong, i was trying to use it in dicString function to remember obtained string. That caused the issue. I fixed that by adding the resource id to the remember function as parameter. remember( id ) { }
这篇关于jetpack撰写java.lang.IllegalStateException:开始/结束不平衡的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!