Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to get android gradient center light effect?

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>  
like image 281
Ajeet47 Avatar asked Oct 23 '13 12:10

Ajeet47


People also ask

What is angle in gradient Android?

attributes: android:angle Integer. The angle for the gradient, in degrees. 0 is left to right, 90 is bottom to top. It must be a multiple of 45.


1 Answers

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" 
like image 118
Himanshu Joshi Avatar answered Sep 21 '22 15:09

Himanshu Joshi