how to get android gradient center light effect?

Ajeet47 picture Ajeet47 · Oct 23, 2013 · Viewed 55.4k times · Source

i want something like following image

enter image description here

i tried it using drawable shape

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" >
<gradient
    android:angle="360"
    android:centerX="50%"
    android:centerY="50%"

    android:gradientRadius="50%"
    android:endColor="#000000"
    android:centerColor="#FFFFFF"
    android:startColor="#000000" >
</gradient>
</shape> 

Answer

Himanshu Joshi picture Himanshu Joshi · Oct 23, 2013

Make a new Android xml file (say GreyRadial.xml) file in your drawable folder

In your xml file

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

    <gradient
        android:centerColor="#c1c1c1"
        android:endColor="#4f4f4f"
        android:gradientRadius="400"
        android:startColor="#c1c1c1"
        android:type="radial" >
    </gradient>

</shape>

Use this xml in your layout background using

android:background="@drawable/GreyRadial"