I find the way Border(1.dp, Color.Black) can not work with the border property of Card view, what's the best way to work around of it?
Asked
Active
Viewed 3.1k times
23
Gabriele Mariotti
- 320,139
- 94
- 887
- 841
ccd
- 5,788
- 10
- 46
- 96
2 Answers
36
You can use the border parameter to specify a BorderStroke to draw the border on top of the card:
Card(
border = BorderStroke(2.dp,Color.Red),
backgroundColor = Color.Yellow){
}
With Material3 you can use:
Card(
border = BorderStroke(2.dp,Color.Red),
colors = CardDefaults.cardColors(containerColor = Yellow)
)
Gabriele Mariotti
- 320,139
- 94
- 887
- 841
26
The border api of Card change to subtitle of Modifier, so it can add a border under below.
Card(modifier = Modifier.border(1.dp, Color.Black)) {...}
ccd
- 5,788
- 10
- 46
- 96
-
4If you are not looking for Some better answer then you should mark it accepted. – ADM Oct 22 '20 at 04:34
