aagam94
aagam94

Reputation: 613

Distorted circle in android using canvas

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

By this code i do get circle ,which is looking as:-

Now the problem is that it doesnt look like a true circle ,and it looks like an oval shape..

So what should i do ??

Thanks in advance,....

Upvotes: 3

Views: 746

Answers (1)

Blackbelt
Blackbelt

Reputation: 157457

iv.setBackgroundDrawable(new BitmapDrawable(bmp));

use setImageBitmap(), instead of setBackgroundDrawable(), and setScaleType() to FIT_CENTER

Upvotes: 2

Related Questions