在我的代码中:
paint.setColor(Color.GRAY);
paint.setAlpha(80);
canvas.drawPath(getPath2(), paint);
public static Path getPath2()
{
Path mPath2 = new Path();
mPath2.moveTo(pta2.x, pta2.y);
mPath2.lineTo(pta.x, pta.y);
mPath2.lineTo(ptb.x, ptb.y);
mPath2.quadTo(ptl.x, ptl.y, ptd.x, ptd.y);
mPath2.close();
return mPath2;
}
你知道我的油漆画了一个灰色,它不透明,渐变,我不知道我是否应该使用paint.setColorFilter,你能告诉我怎么做
答案 0 :(得分:3)
Paint paint = new Paint();
paint.setStyle(Style.FILL);
LinearGradient gradient = new LinearGradient(fromx, fromy, tox, toy, new int[]{color1, color2, color3}, new float[]{0, 0.6f, 1}, TileMode.CLAMP);
paint.setShader(gradient);
canvas.drawPath(getPath2(), paint);