Set image with rounded corners into ImageView

后端 未结 3 1485
南旧
南旧 2021-01-16 22:20

I have a ListView with contact images and names or numbers. Now I want to round the corners of this contact image.

public View getView(final int         


        
3条回答
  •  清歌不尽
    2021-01-16 22:43

    If you are trying to make your imageview as rounded corner
    

    You can achieve this multiple ways

    Method 1:: Use a background drawable which is rounded image(You can use nine-patch)

    Method 2:: You can use these links

    • Post1
    • post2

    Here is an demo answer

    just use XML in case you have some space around the image:

    Create a bordered shape with transparent content like this:

    
    
        
        
     
    

    Then in a RelativeLayout you can first place your image and then in the same location above the shape with another ImageView. The cover-shape should be larger in size by the amount of the border width. Be careful to take a larger corner radius as the outer radius is defined but the inner radius is what covers your image.

    Hope it helps somebody, too.

    Edit as per CQM request the relative layout example:

    
    
    
        
    
        
    
    
    

    Hope it helps

提交回复
热议问题