Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change a button's shape using xml or using java?

I want to make a custom button with shape, how to do this?

like image 620
suresh Avatar asked Jul 13 '11 05:07

suresh


1 Answers

This is the sample button which is of oval shape.. The gradient says the start n end color along with the angle. corners for the oval shape..Try this.. Mention the name of this xml in button background android:background="@drawable/sample".Save the xml in drawable.

<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle">
    <gradient
        android:startColor="#302226"
        android:endColor="#6D7B8D"
        android:angle="45"/>
    <padding android:left="6dp"
        android:top="6dp"
        android:right="6dp"
        android:bottom="6dp" />
    <corners android:radius="30dp" />

</shape>

Also check this link for custom button.

like image 119
Hussain Avatar answered Sep 25 '22 06:09

Hussain