1
votes

I want to make GradientDrawable for background like the image below.

enter image description here

Linear Gradient with same color in the top and bottom.

I made gradient drawable with start, center and end colors but couldn't set the size of center color.

I also tried <Layer-list> with 2 gradient shape-s but one overlays over the other and either I have gradient on the top or on the bottom.

Can anyone help me ?

1
use "rect" ShapeDrawable + ShapeDrawable.ShaderFactory - pskink
dont you know how to use ShapeDrawable.ShaderFactory ? - pskink
@pskink I get the same effect as I had with xml gradient. I can't make center color dominant to take about 80% of screen - Jilberta
yes you can, just use 4 colors and 4 positions in LinearGradient constructor - pskink
@pskink wow Thanks man, I didn't know you could use 4 colors, post as an answer and I'll accept it. - Jilberta

1 Answers

3
votes

use "rect" type ShapeDrawable and ShapeDrawable.ShaderFactory

when implementing ShapeDrawable.ShaderFactory return the LinearGradient using colors array with 4 colors (f.ex: white, dark_blue, dark_blue, white) and positions array with 4 positions (f.ex: 0, 0.2, 0.8, 1)