Code example for LinearGradient

0
            mDrawWidth = 200;
            mDrawHeight = 200;
 
            mGradient = new LinearGradient(0, 0, 0, 1, 0xFF000000, 0, Shader.TileMode.CLAMP);
            mGradientStops = new LinearGradient(0, 0, 0, 1,
                    new int[] { 0xFFFF0000, 0xFF00FF00, 0xFF0000FF }, null, Shader.TileMode.CLAMP);
 
            mMatrix = new Matrix();
 
            mPaint = new Paint();
        } 
 
        @Override 
        protected void onDraw(Canvas canvas) {
            super.onDraw(canvas);
            canvas.drawRGB(255, 255, 255);
 
            // Gradients 
            canvas.save();
            float top = 40.0f;
            float right = 40.0f + mDrawWidth;