3
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));

通过这段代码,我确实得到了圆圈,它看起来像:-

现在的问题是它看起来不像一个真正的圆形,它看起来像一个椭圆形..

所以我该怎么做 ??

提前致谢,....

4

1 回答 1

2
iv.setBackgroundDrawable(new BitmapDrawable(bmp));

使用setImageBitmap()代替,setBackgroundDrawable()setScaleType()FIT_CENTER

于 2012-07-13T13:40:22.673 回答