How to make an image fit into a circular frame in android

后端 未结 7 2054
暖寄归人
暖寄归人 2020-12-01 00:27

I have a ListView in which there is an ImageView, the image in the ImageView gets loaded dynamically after its fetched from the server

7条回答
  •  天命终不由人
    2020-12-01 01:00

    Add following dependancies

     implementation 'jp.wasabeef:picasso-transformations:2.2.1'
     implementation 'de.hdodenhof:circleimageview:3.0.0'
    

    CircularImageView available for image fit in circle also if image is not looking proper .resize is for image resizing in circular image view.

        CircleImageView img;
        String Imageid; 
    
        Imageid="ImageName"; //String is not compulsary it may be drawable  
    
        Picasso.with(mContext)
                .load(Imageid.get(position)) //Load the image
                .error(R.drawable.ic_launcher_background) //Image resource for error
                .resize(20, 20)  // Post processing - Resizing the image
                .into(img); // View where image is loaded.
    

提交回复
热议问题