I am trying to create a component for creating custom shadows for buttons or other components, I know that with a 9-patch file or pager it will be easier, but I want to change its color and size programmatically and in its states (pressed, etc.), so I decided to try with 9 images, all in XML format, so that the shadows displayed their gradient from the component side.
<item> <shape android:shape="rectangle" > <gradient android:angle="0" android:endColor="#FFFF0000" android:startColor="#00FF0000" /> </shape> </item>
It seems that the problem lies in the corners, and the android: gradientRadius parameter is now set to a fixed size, but in the context help they say that you can set 10% p as a percentage of the base size or 10% p of the parent, that I want it to set the radius to 100 % p, so the gradient will always go from the main color and disappear at the edge of the square.
- EDIT -
Android doc about gradientRadius gradientRadius
<shape android:shape="rectangle" > <gradient android:endColor="#00FF0000" android:startColor="#FFFF0000" android:gradientRadius="18" android:centerX="100%" android:centerY="100%" android:type="radial" /> </shape>
And here is where im is now :( I don't know how I can set this size according to its parent representation.
Any help would be appreciated when I finished with the component, I will put the code back :), so typical buttons can have custom shadows in xml.
Image of a well-deserved component.
- Edit -
I'm still wondering this :) no one has a clue?

android android-layout android-xml
Goofyahead
source share