ImageView in circular through xml

前端 未结 27 1286
死守一世寂寞
死守一世寂寞 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:53

    Another idea is to use clipToOutline property of an ImageView.

    Here is an example layout:

    
    
        
        
    
        
        
    
    
    

    And here are our shape_border drawable:

    
    
        
    
    

    And shape_oval drawable:

    
    
    

    The only thing you should do in the code - is to enable clipToOutline property:

    binding.ivImage.clipToOutline = true
    

    And of course you can avoid even this line of the code with some BindingAdapter.

提交回复
热议问题