我正在学习 Jetpack Compose,我正在尝试使用 Modifier 方法高度和填充来自定义图像的显示。但是我收到了问题消息“ Unresolved reference :高度”和“ Unresolved reference :填充”。
@Preview
@Composable
fun imageDisplay() {
Column(
modifier = Modifier.padding(16.dp)
) {
Image(
painter = painterResource(R.drawable.photo_1505740420928_5e560c06d30e),
contentDescription = null,
modifier = Modifier
.height(180.dp)
.fillMaxWidth()
.clip(shape = RoundedCornerShape(4.dp)),
contentScale = ContentScale.Crop
)
}
}
padding and height methods highlighted in red我错过了什么吗?
最佳答案
一切看起来都很好。确保您使用的是最新版本的 Android Studio、gradle 和 compose 版本。
implementation "androidx.compose.ui:ui:$compose_version"
implementation "androidx.compose.ui:ui-tooling:$compose_version"
implementation "androidx.compose.material:material:$compose_version"
implementation "androidx.compose.material:material-ripple:$compose_version"
最后,检查您是否导入了正确的 Modifier
类(class)。您必须使用
androidx.compose.ui
中的那个包裹。
关于android - Jetpack compose 中 Unresolved 修改器方法引用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67264430/