vijay

welcome Netizen

Share Your Knowledge.It is a way to achieve immortality

Wednesday, July 25, 2012

Create different type gradient color in android


Here I will explain to create the different type of gradient color applied in android application.
Normally the gradient colors are used to apply as background color to make our application more style.
In android we can create the three type of gradient color.
1. Linear
2. Radial
3. Sweep
Initially we need to create on xml file with gradient color specification then we can use the xml file throughout the project .we set the xml file as background in any layout used in the activity.
Step 1:
Create new xml file with shape layout,name the xml file bggrad.xml
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle">
    <gradient android:type="linear"
        android:gradientRadius="200"
        android:startColor="#8B8A88"
        android:endColor="#CCCCCC"
        />  
</shape>

Here you can set the gradient type as you like there are three types available linear,sweep and radial by changing the radius the shade will be differ. Also set the start and end color
Step 2:
Then use the xml file as background in your all xml files for example see the below code..
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    android:background="@drawable/bggrad">  
</LinearLayout>

Here I set the background bggrad xml file, so your layout has apply the gradient color.
I hope you like this article ..post your valuable comments here……..




0 comments:

Post a Comment