Draw diagonal line from corner to corner inside RelativeLayout

前端 未结 1 1994
-上瘾入骨i
-上瘾入骨i 2021-01-14 16:16

I\'m new in Android development and I\'m trying to draw a line inside my yellow RelativeLayout from bottom left corner to top right corner. I\'ve added a layer-list

1条回答
  •  臣服心动
    2021-01-14 17:16

    You should use VectorDrawable path to draw line inside yellow RelativeLayout from bottom left corner to top right corner. Your diagonal_line.xml should be like (assume line color is blue #0000FF and line width is 4):

    
    
        
    
    

    (absolute dimensions not important, because vector will be rescaled for RelativeLayout size). Your styles.xml should include section

    
    

    as you wrote, and in case you cannot use backgroundTint in your {your_layout}.xml file, you should set solid colored background (android:background="#FFDC7F") for your Relativelayout and put "dummy" View with diagonalStyle (style="@style/diagonalStyle") over it. Something like that:

    
    
    
        
    
    
    

    As result, you should give something like that:

    More path tutorial here.

    0 讨论(0)
提交回复
热议问题