Drawing top border on a shape on Android

后端 未结 4 1371
滥情空心
滥情空心 2020-12-28 17:33

I\'m creating a custom progress bar (positioned under a WebView) and what I would like to draw is a 1dp-wide line between the WebView and the

4条回答
  •  执念已碎
    2020-12-28 18:25

    I spent a while trying to figure this out as well. Hopefully there is a better way to do it but here is the method I used, which is also kind of hackish, but in case it helps someone, I thought I would share.

    The first item in your layer list should be a solid of whatever color you want to be your border. Following that would be the thing(s) you want to have the border, with padding on whatever side you want the border to be on.

    For example:

    
    
        
            
                
            
        
        
            THE THING YOU WANT A BORDER ON
        
    
    

    The idea is that the padding on the item reveals the solid shape behind it, giving the border appearance. You could add padding to any side to add a border. I imagine you could get more complicated and have different colored borders this way as well.

    Seems like a hack but it worked for me.

    EDIT: I said "padding" but in layer-lists it's more of an offset.

提交回复
热议问题