http://www.2cto.com/kf/201302/190741.html
![](https://img.laitimes.com/img/9ZDMuAjOiMmIsIjOiQnIsIyZuBnL5cjM4ETMxATMzIjMwMTMwIzLcNjMyAzLcNTMwIzLc12bj5yb0NmMuAXdvw1LcpDc0RHaiojIsJye.png)
[html] Paint paint = new Paint(); LinearGradient gradient = new LinearGradient(0, 0, 100, 100, Color.RED, Color.YELLOW, Shader.TileMode.MIRROR); paint.setShader(gradient); canvas.drawRect(0, 0, 100, 100, paint); canvas.drawText("This is the shader", 100, 100, paint);