Pageviews

Sunday 27 October 2013

How to create a new Button shape in Android

by Unknown  |  in Android at  Sunday, October 27, 2013

Basically android give us the by default Button icon,which does not seems to look professional,so in order to make it look more attractive,we have to create a new XML file specially for its shape.So you need to follow the below steps:

Firstly right click on 'res' folder and create a new Android XML file,name it shape.
Now right the following code in your Shape.xml:

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

<corners
android:radius="15dp"
/>
<gradient
android:angle="45"
android:centerX="35%"
android:centerColor="#1E90FF"
android:startColor="#000000"
android:endColor="#000000"
android:type="linear"
/>
<padding
android:left="0dp"
android:top="0dp"
android:right="0dp"
android:bottom="0dp"
/>
<size
android:width="150dp"
android:height="40dp"
/>
<stroke
android:width="3dp"
android:color="#878787"
/>
</shape>

3.Now we have to link this file with the background of our button,so we simply write this code:

android:background="@drawable/shape"

4.Now we are done with changing the look of our button,compare the shapes of button,now and before:















0 comments:

Proudly Powered by Blogger.