关于android中的lineargradient

时间:2013-09-10 11:41:24

标签: android android-canvas surfaceview

我想在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);    
    }

1 个答案:

答案 0 :(得分:1)

您可以使用以下内容使其顺利,

getHolder().setFormat(PixelFormat.RGBA_8888);