Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create rounded border Button using Jetpack Compose

I need to add border with rounded corner in Button using Jetpack Compose

Like :

enter image description here

like image 770
Sanjayrajsinh Avatar asked Nov 15 '19 10:11

Sanjayrajsinh


Video Answer


3 Answers

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" )
}

enter image description here

like image 98
Gabriele Mariotti Avatar answered Oct 19 '22 19:10

Gabriele Mariotti


Just use modifier as:

modifier = Modifier.border( width = 2.dp,
                            color = Color.Red,
                            shape = RoundedCornerShape(5.dp))
like image 30
Pratik Pitale Avatar answered Oct 19 '22 18:10

Pratik Pitale


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))
like image 12
Raheem Jnr Avatar answered Oct 19 '22 20:10

Raheem Jnr