如何在android中使用xml或canvas创建下面图像的形状?

问题描述 投票:1回答:1

reference image

我尝试使用珊瑚画或photoshop制作背景,但无法正常工作。

我应该如何绘制这样的形状?不要指望完整的代码,只是给我一个主意或指出正确的方向。

制作矩形很容易制作形状,但如何添加该右下角的小矩形并将它们制成一个形状,并且由于屏幕尺寸不同,我也想将其制作成九个补丁图像。

android xml android-studio android-custom-view custom-view
1个回答
0
投票

尝试一下...将白色#FFFFFF更改为透明颜色。

我使用https://www.autotracer.org/将png转换为svg,然后使用https://svg2vector.com/将svg转换为矢量

<vector xmlns:android="http://schemas.android.com/apk/res/android" xmlns:aapt="http://schemas.android.com/aapt"
android:viewportWidth="387"
android:viewportHeight="164"
android:width="387dp"
android:height="164dp">
<path
    android:pathData="M0 0L0 164L387 164L387 0L0 0z"
    android:fillColor="#FFFFFF" />
<path
    android:pathData="M15.0154 6.74228C5.65946 10.4321 9 27.0389 9 35L9 122C9 129.655 8.77533 137.349 9.01543 145C9.13696 148.873 10.0384 152.821 14.044 154.397C19.563 156.567 28.1274 155 34 155L80 155C118.722 155 157.279 156 196 156C207.389 156 218.637 155 230 155C236.108 155 243.993 156.326 249.895 154.682C257.017 152.699 256.239 139.506 259.417 134.044C262.869 128.111 270.885 128.508 277 128.09C289.884 127.207 303.085 128 316 128C322.61 128 330.71 127.043 336.985 129.589C347.608 133.9 341.184 148.201 348.43 154.397C352.14 157.569 358.687 155.589 363 155.17C365.594 154.918 368.532 155.301 370.891 153.972C374.586 151.892 374.943 147.798 374.996 144C375.098 136.67 375 129.331 375 122L375 35C375 27.1389 378.249 10.424 368.981 6.74228C361.37 3.71841 349.131 6 341 6L279 6L93 6L39 6C31.9308 6 21.6555 4.12354 15.0154 6.74228z"
    android:fillColor="#D9C4C3" />
<path
    android:pathData="M273 128C278.462 130.292 286.113 129 292 129L332 129C326.538 126.708 318.887 128 313 128L273 128z"
    android:fillColor="#DFD3D3" />
<path
    android:pathData="M15 155C18.9586 156.661 23.7397 156 28 156L53 156L139 156C135.041 154.339 130.26 155 126 155L101 155L15 155M216 155C219.699 156.552 224.017 156 228 156L251 156C247.301 154.448 242.983 155 239 155L216 155M360 155C362.89 156.213 365.874 155.998 369 156C366.11 154.787 363.126 155.002 360 155z"
    android:fillColor="#E1D3D2" />

© www.soinside.com 2019 - 2024. All rights reserved.