Canvas绘制图形

1.Android 利用canvas画各种图形(点、直线、弧、圆、椭圆、文字、矩形、多边形、曲线、圆角矩形)
参考:
https://blog.csdn.net/u013831257/article/details/50556098
https://blog.csdn.net/qq_21751781/article/details/64128399
2.canvas.drawRoundRect方法,绘制圆角矩形
https://blog.csdn.net/liuzhi0724/article/details/44461945
3.Android Canvas设置绘画时重叠部分的处理模式【含效果图】
http://www.cnblogs.com/DonkeyTomy/articles/3215137.html
原理:颜色混合模式(Alpha通道相关)
https://blog.csdn.net/u013831257/article/details/50494832
调用方式

  Paint shaderPaint = new Paint();
    LinearGradient shader = new LinearGradient(0, mHeight, 0,
        flection.getHeight(), 0x70ffffff, 0x00ffffff, TileMode.MIRROR);
    shaderPaint.setShader(shader);
    //android.graphics.PorterDuff.Mode.DST_IN:只在源图像和目标图像相交的地方绘制目标图像
    shaderPaint.setXfermode(new PorterDuffXfermode(android.graphics.PorterDuff.Mode.DST_IN));
     //画出渐变颜色
    canvas.drawRect(0, mHeight+gap, mWidth, background.getHeight(), shaderPaint);

猜你喜欢

转载自blog.csdn.net/hizhangyuping/article/details/82867414