如何在Android

时间:2016-04-25 13:03:02

标签: android android-shape

我想要创建这样的图像形状:
enter image description here

但我不想使用9 pach png图像,我想在可绘制文件夹中创建此形状 我怎么能创造这个? 任何帮助都不胜感激!感谢

1 个答案:

答案 0 :(得分:0)

创建布局

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

在可绘制文件中创建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>

结果

enter image description here