Create Button with rounded corners in android

coderplus picture coderplus · Oct 7, 2012 · Viewed 54.5k times · Source

enter image description here

I'm trying to create a button which looks as in the image above. Initially my idea was to create a 9 patch and set it as the button background. But since, this is a plain button, i think we can somehow draw this without using any images.

The button background color is #0c0c0c The border color is #1a1a1a The text color is #cccccc

I found a similar question on SO but that creates a gradient -
Android - border for button

Answer

Sam picture Sam · Oct 7, 2012

The Android Developer's Guide has a detailed guide on this: Shape Drawbables.

You could also simply remove the gradient element from the link you provided:

<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle">
    <corners android:radius="3dp" />
    <stroke android:width="5px" android:color="#1a1a1a" />
</shape>