ImageView rounded corners

后端 未结 17 2053
长发绾君心
长发绾君心 2020-11-27 15:33

I wanted image to have rounded corners. I implement this xml code and use this in my image view. but image overlap the shape. I am downloading the image through async task.<

17条回答
  •  甜味超标
    2020-11-27 16:26

    Just wondering if anyone still needs it to be done.

    For them: you can use RoundedBitmapDrawable for your purpose.

    Sample Code:

    ImageView profilePic = (ImageView) findViewById(R.idimageView);
    
    RoundedBitmapDrawable roundedBitmapDrawable = RoundedBitmapDrawableFactory.create(this.getResources(),bitmap);
    roundedBitmapDrawable.setCircular(true);
    profilePic.setImageDrawable(roundedBitmapDrawable);
    

    where bitmap is the image you want to load in imageView.

提交回复
热议问题