circular foto android studio code example

Example: como poner foto en redondo android studio

@Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);

      //extraemos el drawable en un bitmap
      Drawable originalDrawable = getResources().getDrawable(R.drawable.image);
      Bitmap originalBitmap = ((BitmapDrawable) originalDrawable).getBitmap();

      //creamos el drawable redondeado
      RoundedBitmapDrawable roundedDrawable =
              RoundedBitmapDrawableFactory.create(getResources(), originalBitmap);

      //asignamos el CornerRadius
      roundedDrawable.setCornerRadius(originalBitmap.getHeight());

      ImageView imageView = (ImageView) findViewById(R.id.imageView);

      imageView.setImageDrawable(roundedDrawable);
  }

Tags:

Misc Example