简体   繁体   English

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

[英]How can I create the following shape in Android?

I am trying to create a following shape in android. 我正在尝试在android中创建以下形状。

在此处输入图片说明 I tried following code but it's only for changing the corners 我尝试了下面的代码,但这仅用于改变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" />

What do I need to make changes in code to achieve the above shape? 我需要对代码进行哪些更改才能实现上述形状?

Edit1 EDIT1

As per the answer I used following code (modifications in layout height): 根据答案,我使用以下代码(布局高度的修改):

<?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>

But when I am using this layout as a background for LinearLayout . 但是当我使用此布局作为LinearLayoutbackground It's showing me this: 它向我展示了这一点:

 <LinearLayout
    android:layout_width="match_parent"
    android:layout_height="0dp"
    android:layout_weight="1"
    android:background="@drawable/header_shape_rect">

在此处输入图片说明

在此处输入图片说明 use this as an example 以这个为例

<?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>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM