ImageView in circular through xml

前端 未结 27 1307
死守一世寂寞
死守一世寂寞 2020-11-22 10:35

I\'d Like to make any image from my ImageView to be circular with a border.

I searched but couldn\'t find any useful information (anything that I tried

27条回答
  •  不知归路
    2020-11-22 10:43

    As was described in Orhan Obut's answer but with the changes:

    // in case of use of weight
    

    to avoid stretches of the image. And img.xml:

    
    
    
    

    (without changes), and circle.xml:

    
    
    
    
     
    

    here the thickness of the ring gotten maximal - 1000dp
    and radiusRatio is a half of image width(max ring width, yes?) - 2
    and the stroke is for required border if needed.
    I used square png image ( profile.png ), btw. With same width and height. This is correct for arbitrary ImageView dimentions.

提交回复
热议问题