英文:
Type mismatch: inferred type is Dp but CardElevation was expected in Jetpack Compose
问题
开始学习Jetpack Compose。出现错误: 类型不匹配:推断类型为Dp,但期望为CardElevation,我不明白问题是什么,告诉我如何解决它。导入了androidx.compose.ui.unit.dp
库,并更新了Jetpack Compose的版本,预计能帮到。
英文:
Started learning Jetpack Compose. An error occurred: Type mismatch: inferred type is Dp but CardElevation was expected, I can't understand what the problem is, tell me how to solve it.
import androidx.compose.ui.unit.dp library imported, and updated versions of Jetpack Compose, expected to help
答案1
得分: 6
如果您正在使用Material 3,那么您需要以以下方式使用CardElevation:
elevation = CardDefaults.cardElevation(defaultElevation = 5.dp)
更多详情请查看这里
英文:
If you are using Material 3, then you need to use CardElevation in this way:
elevation = CardDefaults.cardElevation(defaultElevation = 5.dp)
More details here
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论