kabuto178
kabuto178

Reputation: 3167

Setting a gradient background color for surfaceview

At the moment i have a static plain blue background color on my surfaceview, I wanted to know a way to get a blue gradient from deep blue to light blue vertically. Currently I set the background color like this

         canvas.drawRGB(15,03,175);

Any tips or advice will be appreciated, thank you.

Upvotes: 0

Views: 1760

Answers (1)

kabuto178
kabuto178

Reputation: 3167

Found my answer in the form of paint's set shader, this works nicely for the moment

         Paint gradPaint = new Paint();
         gradPaint.setShader(new LinearGradient(0,0,0,getHeight(),Color.BLUE,Color.CYAN,Shader.TileMode.CLAMP));
         canvas.drawPaint(gradPaint);
         //Where getHeight() is the height of the canvas

Upvotes: 2

Related Questions