Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android radial gradient

I've got following drawable set as LinearLayout background:

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
   <item>
      <bitmap
         android:tileMode="repeat"
         android:dither="true"
         android:src="@drawable/bg"/>
   </item>


   <item>
      <shape android:shape="rectangle">
         <gradient
            android:startColor="#ffff0000"
            android:endColor="#ff00ff00"
            android:centerX="50%"
            android:centerY="50%"
            android:gradientRadius="50%"
            android:type="radial"/>
      </shape>
   </item>
</layer-list>

According to the docs, gradientRadius can be set to percentage of window/parent size. Unfortunetely... it's not working. The radius is 0. What am I doing wrong? Or what's wrong with Android?

I need the radial gradient to fill the whole screen. What's the workaround?

like image 481
Sebastian Nowak Avatar asked May 27 '12 14:05

Sebastian Nowak


1 Answers

A little bit late, but according to docs, you must set "50%p", not "50%". (Note the 'p' which indicates 'parent')

like image 111
Daniel Avatar answered Sep 30 '22 18:09

Daniel