基本上是一样的吧?它们具有相同的属性。我真的不知道什么时候必须使用每一个。
从技术上讲,Cards 用于卡片视图,但 Surface 具有相同的属性,如elevation
和border
android android-jetpack-compose android-compose-card android-jetpack-compose-surface
当我单击涟漪效应传播而不考虑表面的形状时,我可以在 gif 中看到 3 个表面。
哪些是用
@Composable
fun SurfaceClickPropagationExample() {
// Provides a Context that can be used by Android applications
val context = AmbientContext.current
// Offset moves a component in x and y axes which can be either positive or negative
// When a component inside surface is offset from original position it gets clipped.
Box(
modifier = Modifier
.fillMaxWidth()
.wrapContentHeight()
.clipToBounds()
.clickable(onClick = {})
) {
Surface(
modifier = Modifier
.preferredSize(150.dp)
.padding(12.dp)
.clickable(onClick = {
})
.clipToBounds(),
elevation …
Run Code Online (Sandbox Code Playgroud) android android-jetpack-compose android-jetpack-compose-surface