Android: give a webview rounded corners?

前端 未结 6 1878
隐瞒了意图╮
隐瞒了意图╮ 2020-12-17 14:27

I\'m trying to give my webView rounded corners.

Here is my code:

rounded_webview.xml:




        
6条回答
  •  清酒与你
    2020-12-17 14:58

    I use an image that looks like a picture frame, where I give the frame the rounded corners. I lay this picture frame over the view I'm trying to give the rounded corners to.

    This gets over the problem in iBog's solution of background panels not working nicely.


    The trick is to use a RelativeLayout; place your layout inside it. Below your layout, add another ImageView, setting its background to a suitable masking image frame. This will draw that on top of your other layout.

    In my case, I made a 9Patch file which was a grey background, with a transparent rounded rectangle cut out of it.

    frame

    This creates the perfect mask for your underlying layout.

    The XML code could be something like this:

    
    
        
    
        
        
    
    
    

    The full details can be found in my original answer here:

    • Android XML rounded clipped corners

提交回复
热议问题