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,....

Answers


iv.setBackgroundDrawable(new BitmapDrawable(bmp));

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


Need Your Help

Multiple Annotations ( MKAnnotationView ) in the same location Coordinates

iphone ios objective-c annotations mapkit

Hi I am trying to implement Annotations grouping and animation if the user touch.

Is there an database connectivity framework or library for PHP?

php mysql database database-connection

I wonder if there's a useful library or lightweight framework only for database connectivity. What I need is something that lets me use a MySQL database with prepared statements in a secure way, wi...