Crop and set image in RoundShape without using any library in Android

RoundedBitmapDrawable is support library by android, which is very simple and 
light-weight to use for cropping image in rounded shape.

Have a look at example....

   Bitmap placeHolder = BitmapFactory.decodeResource(getResources(), 
                                            R.drawable.user_placeholder);
   RoundedBitmapDrawable roundedBitmapDrawable = 
                RoundedBitmapDrawableFactory.create(getResources(),placeHolder);
   //setting radius
roundedBitmapDrawable.setCornerRadius(10.0f);
roundedBitmapDrawable.setCircular(true);
roundedBitmapDrawable.setAntiAlias(true);
imgLogo.setScaleType(ImageView.ScaleType.FIT_XY);
imgLogo.setImageDrawable(roundedBitmapDrawable);
and done...

Comments