我想在画布上绘制具有以下形状的图像:
黑色必须由我的图像替换。我目前正在绘制整个图像。我只是不知道我怎么能得到那种形状?
canvas.drawBitmap(header,0,0,mPaint);
有人能帮我吗?
感谢pskink我得到了它:
int width = this.getMeasuredWidth();
int height = this.getMeasuredHeight();
BitmapShader shader;
shader = new BitmapShader(header, Shader.TileMode.CLAMP, Shader.TileMode.CLAMP);
mPaint.setShader(shader);
Path path = new Path();
path.moveTo(0,0);
path.lineTo(0,height/2);
path.lineTo(width,height/4);
path.lineTo(width,0);
canvas.drawPath(path,mPaint);
只需使用着色器和路径即可完成工作。