圆角边缘不平滑(在android中使用drawRoundRectangle)

圆角边缘不平滑(在android中使用drawRoundRectangle),android,android-canvas,Android,Android Canvas,我在画布中使用drawRoundRect函数来绘制一个圆边矩形。当x和y半径很小(如3)时,曲线看起来很平滑。但是当我把半径增加到20时,边缘不光滑,看起来也不好。有人能帮我吗 我的构造函数中有以下代码 paint= new Paint(Paint.ANTI_ALIAS_FLAG); paint.setColor(Color.RED); // set default color to white Bitmap src = BitmapFacto

我在画布中使用drawRoundRect函数来绘制一个圆边矩形。当x和y半径很小(如3)时,曲线看起来很平滑。但是当我把半径增加到20时,边缘不光滑,看起来也不好。有人能帮我吗

我的构造函数中有以下代码

 paint= new Paint(Paint.ANTI_ALIAS_FLAG);
            paint.setColor(Color.RED); // set default color to white 
            Bitmap src = BitmapFactory.decodeResource(getResources(),R.drawable.texture);   
            Rect tempRect = new Rect(0, 0, src.getWidth(), src.getHeight());
            Bitmap tile = Bitmap.createBitmap(src, tempRect.left,
                    tempRect.top, tempRect.right - tempRect.left,
                    tempRect.bottom - tempRect.top);
            BitmapShader bs = new BitmapShader(tile, TileMode.REPEAT, TileMode.REPEAT);
            paint.setShader(bs);
            rect=new RectF(20,20,600,200);
我在昂德劳打电话

canvas.drawRoundRect(rect, 20, 20, paint);

要绘制平滑的角点,请使用抗锯齿

final Paint paint = new Paint();
paint.setAntiAlias(true);
paint.setColor(color);
paint.setXfermode(new PorterDuffXfermode(Mode.SRC_IN));
然后使用

canvas.drawRoundRect(rect, 20, 20, paint);

我意识到这是旧的。然而,问题是重新绘制。
由于消除混叠的工作原理,如果您在不清除位图的情况下重新绘制形状。结果是边缘粗糙。我已经更详细地介绍了这一点。

为paint object设置
抗锯齿
为true显示此处的代码它对您很有帮助。我正在创建这样的paint对象:paint paint=new paint(paint.ANTI_ALIAS_标志);我试过用它。但曲线并不平滑。