简体   繁体   中英

How to create this shape in Android

I want create shape such as this image :
在此输入图像描述

But i do not want use 9 pach png image, i want create this shape in drawable folder.
How can i create this? Any help could be appreciated! Thanks

Create your layout

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/activity_main7"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context="com.ul_ts.emvsdktester.drawabletraining.Main7Activity">


    <LinearLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerInParent="true"
        android:background="@drawable/my_shape4"></LinearLayout>

</RelativeLayout>

Create my_shape4.xml in your drawable file

<?xml version="1.0" encoding="utf-8"?>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
    android:width="100dp"
    android:height="100dp"
    android:viewportHeight="100"
    android:viewportWidth="100">
    <group>
        <path
            android:pathData="M0 20 L50 20 L60 0 L100 0"
            android:strokeColor="#000000"
            android:strokeWidth="4" />
        <path
            android:fillColor="#42ce3b"
            android:pathData="M100 0 L100 50 L0 50 L0 20 L50 20 L60 2 L100 2"
            android:strokeWidth="0" />
    </group>
</vector>

The results

在此输入图像描述

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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