开发者

What is difference between black and other colors in Android?

开发者 https://www.devze.com 2023-04-05 05:59 出处:网络
I\'m just trying to draw line by touch event in android. But some problem is here. When I try to draw black line, it works normally.

I'm just trying to draw line by touch event in android. But some problem is here.

When I try to draw black line, it works normally. But When I try to draw line using other colors, it makes some kind of shade..

I want to know the reason why.

public void run(){
    int tempAngle;
    Canvas canvas = null;
    while(flag){
        canvas = mHolder.lockCanvas();
        try{
            synchronized (mHolder) {

                canvas.drawBitmap(imgBack, 0,0,null);//draw background image(.png)
                tempAngle = chec开发者_如何学PythonkAngle((int)x2,(int)y2);

                if(centerFlag2){
                    // mPaint.setColor(Color.Black) is working normally, but other
                    // colors(Color.WHITE,RED,.etc) makes some kind of shade.
                    // It just keep exists past lines on surface view. 
                    // But I don't know the reason why.
                    canvas.drawLine(width/2, width/2, x1, y1, mPaint);//draw a line.
                    checkNumber(tempAngle);
                    }

                if(centerFlag){
                canvas.drawLine(width/2, width/2, x1, y1, mPaint);
                checkNumber(tempAngle);
                }
                if(hourFlag){
                    canvas.drawLine(width/2, width/2, tempX, tempY, mPaint2);
                }
            }

        }finally{
            if(canvas!=null){
                mHolder.unlockCanvasAndPost(canvas);
            }
        }
    }

}


I solved this problem myself. sigh. The reason is view's basic color was black.

My background image was transparency.

I changed my image's background color to black. that's it. :D

anyway, thank you guys.


Let's try to set ARGB color code as like this mPaint.setARGB(255, 255, 0, 0);

0

精彩评论

暂无评论...
验证码 换一张
取 消