1

尝试使用透明背景绘制并在其上绘制线条。然而,它绘制了一个黑色矩形而不是 transparet。如果我将颜色更改为红色,它可以正常工作。所以我猜这是透明的问题。

       drawPoints[currentpoint*4+0] = 0; 
       drawPoints[currentpoint*4+1] = 10;
       drawPoints[currentpoint*4+2] = 20; 
       drawPoints[currentpoint*4+3] = 40;

        Canvas mCanvas = sfh.lockCanvas(new Rect(10,20,50,100));
        mCanvas.drawColor(Color.TRANSPARENT);           
        mCanvas.drawLines(drawPoints,mPaint);
        sfh.unlockCanvasAndPost(mCanvas);

为什么会画黑色?

4

3 回答 3

7

如果你想要透明度,你可以尝试:

mPaint.setAlpha(100);

或 0 到 255 之间的某个值。

希望有帮助。

于 2012-07-02T22:38:41.957 回答
0

I find this on the internet, I think that can works

Paint pincel1=new Paint();
paint.setARGB(255,255,0,0);

canvas.drawRect(10,10,ancho-10,40,pincel1);

pincel1.setStyle(Style.STROKE);
canvas.drawRect(10,60,ancho-10,90,pincel1);

pincel1.setStrokeWidth(3);
canvas.drawRect(10,110,ancho-10,140,pincel1);

image http://www.javaya.com.ar/androidya/imagentema/foto137.jpg

thx javaya.com/ar for the code

code

于 2014-12-11T12:55:41.250 回答
0

您想将 Paint 对象的颜色设置为 Color.TRANSPARENT,而不是画布的颜色。所以试试

mPaint.setColor(Color.TRANSPARENT);
于 2012-07-02T22:49:49.440 回答