Skip to content Skip to sidebar Skip to footer

How I Can Do A Button With Left/right Side As Rounded As Circle

I'm trying to do a button with the sides rounded, but when I change the size of screen the button sides left to be rounded as circles, doesn't mantain the aspect ratio (I think). I

Solution 1:

The other answers are correct... almost: if you will set corners to some value (let's say 20dp), but your button height will be greater (like 40dp) - you will end with rounded corners instead of rounded sides. The solution is thus straightforward: set android:corners attribute to some high enough value that will be greater than button height:

<?xml version="1.0" encoding="utf-8"?><shapexmlns:android="http://schemas.android.com/apk/res/android"android:shape="rectangle"><solidandroid:color="@color/colorPrimary" /><cornersandroid:radius="200dp" /><sizeandroid:height="16dp"android:width="32dp" /></shape>

enter image description here

Solution 2:

Create a drawable resource file in xml. The following is code for a blue button

<shapexmlns:android="http://schemas.android.com/apk/res/android"android:shape="rectangle"><solidandroid:color="#2196f3"></solid><cornersandroid:radius="12dp"></corners></shape>

Then just asign this resource file as the background to one of your textViews

I hope this helps

Solution 3:

<?xml version="1.0" encoding="utf-8"?><shapexmlns:android="http://schemas.android.com/apk/res/android"android:shape="rectangle"><cornersandroid:radius="20dp" /><solidandroid:color="#1ee" /></shape>

Post a Comment for "How I Can Do A Button With Left/right Side As Rounded As Circle"