Making an image circular with white circular border

后端 未结 10 2468
甜味超标
甜味超标 2021-02-19 19:32

How to make an image circular and give it white circular border? Is it necessary to use two image views – one for the image and other for the white border? Is there any other wa

10条回答
  •  遥遥无期
    2021-02-19 20:12

    This may not be the best way and you may not be able to change a lot of properties, but it is surely the easiest way. I just used this library and I made a circular imageview that has also a border.


    So, this is my solution:

    First, I put this in my build.grandle:

    `compile 'com.github.siyamed:android-shape-imageview:0.9.+@aar'`
    

    Second, I put this in my .xml layout file:

     
    

    In my .java file, this is the way I can take or set the image to the CircularImageView:

    final com.github.siyamed.shapeimageview.CircularImageView photo = (com.github.siyamed.shapeimageview.CircularImageView) convertView.findViewById(R.id.photo);
    
    photo.setBackgroundResource(R.drawable.female);
    

    That's all I've done to do the an image circular with white border.

提交回复
热议问题