如何在Android中创建以下形状?

时间:2017-03-07 10:25:07

标签: android android-layout android-studio android-shape android-shapedrawable

我正在尝试在android中创建以下形状。

enter image description here我尝试了以下代码,但仅用于更改corners

<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" >

<solid android:color="#ffffff" />

<gradient
    android:startColor="#00EBCF"
    android:endColor="#00BEEC"
    android:angle="180"
    android:type="linear" />

<corners
    android:bottomLeftRadius="80dp"
    android:bottomRightRadius="80dp"
    android:topLeftRadius="0dp"
    android:topRightRadius="0dp" />

我需要在代码中进行哪些更改才能实现上述形状?

EDIT1

根据我使用以下代码的答案(布局高度的修改):

<?xml version="1.0" encoding="utf-8"?>

                          

    </shape>
</item>

<item
    android:width="1500dp"
    android:height="200dp"
    android:top="95dp">
    <shape android:shape="oval">
        <solid android:color="#36D6E9" />

    </shape>
</item>

但是当我将此布局用作background的{​​{1}}时。它告诉我这个:

LinearLayout

enter image description here

1 个答案:

答案 0 :(得分:0)

enter image description here以此为例

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">

    <item android:height="200dp">
        <shape android:shape="rectangle">
            <solid android:color="#ccc"/>
        </shape>
    </item>

    <item android:height="200dp" android:top="95dp" android:width="1500dp" >
        <shape android:shape="oval">
            <solid android:color="#ccc"/>
        </shape>
    </item>

</layer-list>