Modifier 边框(Border)


Modifier 边框(Border)

fun Modifier.border(border: BorderStroke, shape: Shape)
fun Modifier.border(width: Dp, color: Color, shape: Shape)
fun Modifier.border(width: Dp, brush: Brush, shape: Shape)
Column {
    Text(
        "Text with  square border",
        modifier = Modifier
        .border(4.dp, Color.Magenta,
                shape = CutCornerShape(8.dp))
        .padding(10.dp)
    )

    Text(
        "Text with gradient border",
        modifier = Modifier
        .border(
            border = BorderStroke(2.dp, Color.Blue),
            shape = CutCornerShape(8.dp)
        )
        .padding(10.dp)
    )

    val gradientBrush = Brush.horizontalGradient(
        colors = listOf(Color.Red, Color.Blue, Color.Green),
        startX = 0.0f,
        endX = 500.0f,
        tileMode = TileMode.Repeated
    )

    Text(
        "Text with gradient border",
        modifier = Modifier
        .border(width = 2.dp, brush = gradientBrush, shape = CircleShape)
        .padding(10.dp)
    )
}

文章作者: Vinx
版权声明: 本博客所有文章除特別声明外,均采用 CC BY 4.0 许可协议。转载请注明来源 Vinx !
  目录