how to make a capsule shape Button in android?

user3393926 picture user3393926 · Dec 30, 2014 · Viewed 42.4k times · Source

I want to make a button exactly like in this image

Capsule button

I want to use a xml file that will used to produce such button. Can anyone tell me how to do that?

Answer

user3393926 picture user3393926 · Dec 30, 2014

finally I found the way to do it with xml file. here is the code of the xml file that gave me the capsule shape button.

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" >

  <corners
    android:bottomLeftRadius="30dp"
    android:bottomRightRadius="30dp"
    android:radius="60dp"
    android:topLeftRadius="30dp"
    android:topRightRadius="30dp" />

  <solid android:color="#CFCFCF" />

  <padding
    android:bottom="0dp"
    android:left="0dp"
    android:right="0dp"
    android:top="0dp" />

  <size
    android:height="60dp"
    android:width="270dp" />

</shape>