Jetpack Compose 之 Surface

507 阅读1分钟

属性

@Composable
fun Surface(
    modifier: Modifier = Modifier,
    //形状
    shape: Shape = RectangleShape,
    //颜色
    color: Color = MaterialTheme.colors.surface,
    //内容颜色
    contentColor: Color = contentColorFor(color),
    //边框
    border: BorderStroke? = null,
    elevation: Dp = 0.dp,
    content: @Composable () -> Unit
)

案例

Surface(
    modifier = Modifier.size(100.dp),
    shape = RoundedCornerShape(10.dp),
    color = Color.Green,
    contentColor = Color.Blue,
    border = BorderStroke(width = 2.dp, Color.Red),
    elevation = 3.dp
) {
 Text(text = "Surface")
}