How to make a view with rounded corners?

前端 未结 20 1390
遇见更好的自我
遇见更好的自我 2020-11-27 11:08

I am trying to make a view in android with rounded edges. The solution I found so far is to define a shape with rounded corners and use it as the background of that view.

20条回答
  •  天命终不由人
    2020-11-27 11:47

    Create a xml file under your drawable folder with following code. (The name of the file I created is rounded_corner.xml)

    rounded_corner.xml

        
        
    
            
            
            
    
            
            
            
    
            
            
            
    
            
            
            
        
    

    And keep this drawable as background for the view to which you want to keep rounded corner border. Let’s keep it for a LinearLayout

        
    
                
    
        
    

提交回复
热议问题