簡體   English   中英

如何在Android中創建此形狀

[英]How to create this shape in Android

我想創建像這樣的圖像形狀:
在此輸入圖像描述

但我不想使用9 pach png圖像,我想在drawable文件夾中創建這個形狀。
我怎么能創造這個? 任何幫助都不勝感激! 謝謝

創建您的布局

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

在drawable文件中創建my_shape4.xml

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

結果

在此輸入圖像描述

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM