1

我想在 中实现一个LinearGradient效果SurfaceView,但是显示不流畅。它在屏幕上显示一些行。是显示器本身的原因吗?这是我的代码:

    try {    
        canvas = sfh.lockCanvas(); 
        canvas.drawColor(Color.TRANSPARENT,Mode.CLEAR);
        paint = new Paint();   
        linearGradient = new LinearGradient(0,0,0,ScreenH,new int[]{Color.argb(230,255,200, 236),Color.argb(200,255, 153,153)},null,TileMode.CLAMP); 

        paint.setShader(linearGradient);  
        paint.setAntiAlias(true);
        paint.setDither(true);
        canvas.drawPaint(paint);

    } catch (Exception ex) {    
    } finally {     
        if (canvas != null)    
            sfh.unlockCanvasAndPost(canvas);    
    }
4

1 回答 1

1

您可以使用以下使其平滑,

getHolder().setFormat(PixelFormat.RGBA_8888);
于 2013-09-10T11:59:02.633 回答