How to remove border only from one side of the element?

后端 未结 3 1360
暗喜
暗喜 2021-02-01 22:43

I have:


I\'d like to remove this border from the bottom (for example) of the el

3条回答
  •  醉话见心
    2021-02-01 23:24

    This is a bit of a hack, but its possible to remove one or more borders using an inset drawable with negative values. Wrap the shape in an inset and apply a negative android:insetTop, android:insetBottom, android:insetLeft, or android:insetRight with abs value equal to the stroke width.

    enter image description here

    For example, to remove the bottom border from a rectangle with a 4dp stroke, use a android:insetBottom value of -4dp.

    
    
    
        
            
            
            
        
    
    
    

    This seems to work well as long as the shape's corners have a radius that is less than equal to the stroke width. Otherwise use the larger of the two values (the radius) when applying the inset in order to completely hide the rounded portions of the adjacent borders.

提交回复
热议问题