使用canvas实现android中的扭曲圆
通过这段代码,我得到了一个圆,它看起来是:- 现在的问题是它看起来不像一个真正的圆,它看起来像一个椭圆形 那我该怎么办 提前谢谢使用canvas实现android中的扭曲圆,android,canvas,bitmap,geometry,Android,Canvas,Bitmap,Geometry,通过这段代码,我得到了一个圆,它看起来是:- 现在的问题是它看起来不像一个真正的圆,它看起来像一个椭圆形 那我该怎么办 提前谢谢 Paint p = new Paint(); p.setAntiAlias(true); p.setColor(Color.DKGRAY); int y=getWindowManager().getDefaultDisplay().getWidth(); Config conf = Bitmap.Config.RGB_565;
Paint p = new Paint();
p.setAntiAlias(true);
p.setColor(Color.DKGRAY);
int y=getWindowManager().getDefaultDisplay().getWidth();
Config conf = Bitmap.Config.RGB_565;
Bitmap bmp =Bitmap.createBitmap(y,y,conf);
Canvas c = new Canvas(bmp);
c.drawCircle(y/2 ,y/2, y/3, p);
iv.setBackgroundDrawable(new BitmapDrawable(bmp));
使用,而不是
setBackgroundDrawable()
,和setScaleType()
来FIT_CENTER
——如果我想做这个圆圈的动画,我应该做什么?检查Android动画框架。它使用起来非常简单。而且,因为这是另一个问题,所以你应该打开一个新的OP
iv.setBackgroundDrawable(new BitmapDrawable(bmp));