Android button with background

     If you want to create a background for UI components like Buttons or Edit Text etc.,First you have to create xml file in your drawable folder.


yellow_border_gradient.xml
<?xml version="1.0" encoding="UTF-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
 android:shape="rectangle">
 <gradient android:startColor="#FFEC8B" android:endColor="#FFFFFF"
 android:angle="90"/>
 <stroke android:width="1dip" android:color="#8E8E8E" />
 <corners android:radius="5dip" />
 <padding android:left="0dip" android:top="0dip" android:right="0dip"
  android:bottom="0dip" />
</shape>

     After creating the folder you can use the above code for designing, after saving your xml. you can call your xml in your button or any UI component. for example shown below

<Button android:textSize="14dip" android:id="@+id/thank_button"
android:layout_height="wrap_content" android:layout_width="fill_parent"
android:background="@drawable/yellow_border_gradient"></Button>

Your output will like this..

Comments

Popular posts from this blog

Input filter (space not allowed) for EditText

Android Versions details

English - Formal and Informal words