Q:

Android - how to draw 2-directional gradient? 

I started playing with gradients and I've found it's pretty easy to draw 1-directional gradient (like from top to bottom, from left to right, or in diagonale...) but how to draw 2-directional gradient?  I mean something like this:

Big blue rectangle it's 2-directional gradient - on top right corner there is blue and to the left its transforming to white and to the bottom it's transforming to the black.  How to draw this? 

A:

Answer is: you must combine 2 different LinearGradients, for example:
LinearGradient val = new LinearGradient(0, 0, 0, height, Color. WHITE, Color. BLACK, TileMode. CLAMP);
                LinearGradient sat = new LinearGradient(0, 0, width, 0, Color. WHITE, Color. HSVToColor(hsvCopy), TileMode. CLAMP);
                ComposeShader merged = new ComposeShader(val, sat, PorterDuff. Mode. MULTIPLY)

;
And of course important:
[view with this background].setLayerType(View. LAYER_TYPE_SOFTWARE, null);

on phones with 3.0 android and higher

