How can I recreate this background in xml?

前端 未结 2 1689
滥情空心
滥情空心 2020-12-06 07:01

I\'ve been trying to recreate a background image in xml (as drawable). Since the background is a simple shape, it would be better if it is created as xml drawable.

T

相关标签:
2条回答
  • 2020-12-06 07:41

    Try this

    <?xml version="1.0" encoding="utf-8"?>
    <layer-list xmlns:android="http://schemas.android.com/apk/res/android">
        <item>
            <shape android:shape="rectangle" />
        </item>
        <item
            android:bottom="300dp"
            android:left="-100dp"
            android:right="-100dp"
            android:top="-80dp">
            <shape android:shape="oval">
                <size android:height="20dp" />
                <gradient
                    android:angle="0"
                    android:centerColor="@color/colorAccent"
                    android:endColor="@color/red"
                    android:startColor="@color/colorPrimary"
                    android:type="linear" />
            </shape>
        </item>
    </layer-list>
    

    OUTPUT

    0 讨论(0)
  • 2020-12-06 07:54

    Try this

        <layer-list xmlns:android="http://schemas.android.com/apk/res/android"> <item>
              <shape android:shape="rectangle" >
            <solid android:color="#ffffff"/>
        </shape>
     </item> <item
            android:bottom="400dp"
            android:left="-200dp"
            android:right="-200dp"
            android:top="-100dp">
            <shape android:shape="oval">
                <size android:height="20dp" />
                <gradient
                    android:type="linear"
                    android:startColor="#FD4F33"
                    android:centerColor="#EE3A53"
                    android:endColor="#DF2772"
                    android:angle="0" />
            </shape> </item> </layer-list>
    

    The background will be like this

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