Type mismatch: 推断类型为 Dp,但 Jetpack Compose 预期为 CardElevation。

huangapple go评论89阅读模式
英文:

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.
Type mismatch: 推断类型为 Dp,但 Jetpack Compose 预期为 CardElevation。

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

huangapple
  • 本文由 发表于 2023年6月6日 03:16:58
  • 转载请务必保留本文链接:https://go.coder-hub.com/76409403.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定