'How to create rounded border Button using Jetpack Compose
Solution 1:[1]
To achieve a button with a border with rounded corners you can use the OutlinedButton component applying in the shape parameter a RoundedCornerShape:
OutlinedButton(
onClick = { },
border = BorderStroke(1.dp, Color.Red),
shape = RoundedCornerShape(50), // = 50% percent
// or shape = CircleShape
colors = ButtonDefaults.outlinedButtonColors(contentColor = Color.Red)
){
Text( text = "Save" )
}
Solution 2:[2]
Just use modifier as:
modifier = Modifier.border( width = 2.dp,
color = Color.Red,
shape = RoundedCornerShape(5.dp))
Solution 3:[3]
use Clip Modifier, plus you can also choose a specific corner to curve
modifier = Modifier.clip(RoundedCornerShape(15.dp, 15.dp, 0.dp, 0.dp))
Solution 4:[4]
Use the clip Modifier.
Modifier.clip(CircleShape)
Solution 5:[5]
This is the button you have in that image :
Button(
onClick = {},
shape = RoundedCornerShape(23.dp),
border = BorderStroke(3.dp, Color.Red),
colors = ButtonDefaults.buttonColors(contentColor = Color.Red, backgroundColor = Color.White)
) {
Text(
text = "Save",
fontSize = 17.sp,
modifier = Modifier.padding(horizontal = 30.dp, vertical = 6.dp)
)
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | |
| Solution 2 | Pratik Pitale |
| Solution 3 | Raheem Jnr |
| Solution 4 | Pylyp Dukhov |
| Solution 5 | Mahdi nezam parast |


