Nested shapes in Android

后端 未结 1 1050
暗喜
暗喜 2021-01-07 02:32

I am trying to draw a shape that has three rectangular shapes:

  1. solid color
  2. gradient
  3. white line

How do I do that?

W

相关标签:
1条回答
  • 2021-01-07 03:10

    If you're going to look into using multiple shapes, you should try a LayerListDrawable. Something like this works for me, but only for your example height of 60px. You may have to modify it to suit your needs exactly, but this should get you a good start:

    <?xml version="1.0" encoding="utf-8"?>
    <layer-list xmlns:android="http://schemas.android.com/apk/res/android">
    <item>
        <shape android:shape="rectangle">
            <gradient
                android:angle="270"
                android:endColor="#ff16c0e3"
                android:startColor="#ff297baf"
                android:type="linear" />
        </shape>
    </item>
    <item android:top="57px">
        <shape android:shape="rectangle">
            <solid android:color="#FFFFFFFF" />
            <size android:height="3px" />
        </shape>
    </item>
    

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