我想在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);
}
答案 0 :(得分:1)
您可以使用以下内容使其顺利,
getHolder().setFormat(PixelFormat.RGBA_8888);