首页 > 解决方案 > Android Vector Drawable - 带弯角的六边形

问题描述

我想在矢量可绘制中创建一个六边形。我能够找到这样的东西,除了它没有圆角。

<path android:name="hexagon"
    android:fillColor="#aa0000"
    android:strokeColor="#000000"
    android:strokeWidth="4"
    android:pathData="
    m723,314c-60,103.9 -120,207.8 -180,311.8 -120,0 -240,0
    -360,0C123,521.8 63,417.9 3,314 63,210.1 123,106.2
     183,2.2c120,0 240,0 360,0C603,106.2 663,210.1 723,314Z" /> 

你能给我一些提示如何创建它,如图所示

我仍然试图了解这些曲线是如何工作的,但我无法弄清楚。

任何帮助表示赞赏。

标签: android-vectordrawable

解决方案


您可以使用 Adob​​e Illustrator 或Inkspace将图像转换为SVG文件。然后将SVG文件上传到Shape Shifter,Shape Shifter 将为您提供用于矢量图像的路径和文件。

<vector
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:name="vector"
    android:width="160dp"
    android:height="160dp"
    android:viewportWidth="160"
    android:viewportHeight="160">
    <path
        android:name="hexagon"
        android:fillColor="#aa0000"
        android:strokeColor="#000000"
        android:strokeWidth="4"
        android:pathData="M 45.856 145.287 C 42.844 143.796 39.144 141.246 37.635 139.621 C 32.787 134.403 7.938 90.337 6.681 84.732 C 4.518 75.078 6.223 70.935 26.735 36 C 41.676 10.554 41.433 10.667 81.344 10.667 C 121.707 10.667 119.656 9.431 141.095 46.671 C 155.423 71.56 157.469 77.508 154.645 86.066 C 153.736 88.819 147.283 101.031 140.304 113.203 C 119.796 148.969 121.578 147.93 80.667 147.97 C 53.825 147.996 50.868 147.768 45.856 145.287 Z"/>
</vector>

推荐阅读