Code example for Paint

Methods: setShader

0
            super(context);
        } 
 
        @Override 
        protected void onDraw(Canvas canvas) {
            Paint p = new Paint();
            p.setShader(new LinearGradient(0.0f, 0.0f, 0.0f, getHeight(), 0xff000000,
                    0xff333333, Shader.TileMode.CLAMP));
 
            canvas.drawRect(0.0f, 0.0f, getWidth(), getHeight(), p);
        } 
    } 
}