创建具有模糊、颜色和 Y 偏移的阴影



我正在尝试创建具有以下特定属性的阴影: 模糊 , Y 偏移 , 颜色。(由客户指定,使用Zeplin生成版图设计:链接(

但是我不能仅使用"海拔"属性来执行此操作。 我唯一找到这些属性的地方是使用这个网站创建一个 9 个补丁的映像: http://inloop.github.io/shadow4android

但是它的问题在于它调整了我的XML元素(卡视图,按钮...

还有其他方法可以在Android中创建阴影吗?

  1. 您可以将 png 图像转换为 SVG。

  2. 然后,您可以将该SVG转换为Android中的矢量可绘制对象。您可以使用下面提到的在线转换器( http://a-student.github.io/SvgToVectorDrawableConverter.Web/

示例图像的相关可绘制对象如下所示。(有点不同(您可以按照上述步骤自己做。

**但是有一些限制,请提供可以正确转换为svg的png。

<?xml version="1.0" encoding="utf-8"?>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:viewportWidth="234"
android:viewportHeight="234"
android:width="292.5dp"
android:height="292.5dp">
<group
android:scaleX="0.1"
android:scaleY="-0.1"
android:translateY="234">
<path
android:pathData="M256 2252c-11 -9 -16 -12 -12 -5 4 7 -1 9 -14 6 -11 -3 -18 -8 -16 -12 2 -3 -7 -11 -20 -18 -13 -6 -22 -7 -18 -2 3 5 1 9 -4 9 -5 0 -12 -9 -15 -21 -4 -13 -10 -18 -18 -13 -8 4 -10 3 -5 -4 4 -8 0 -12 -11 -12 -11 0 -14 -3 -7 -8 7 -5 7 -14 -1 -29 -7 -13 -14 -20 -17 -18 -3 3 -8 -3 -11 -15 -3 -13 -1 -18 6 -13 7 3 4 -3 -7 -15 -15 -18 -16 -24 -6 -37 7 -8 9 -15 4 -15 -5 0 -9 -379 -9 -864 0 -492 4 -862 9 -859 5 3 4 -3 -2 -13 -8 -15 -7 -24 6 -38 9 -11 12 -16 5 -13 -7 5 -9 0 -6 -13 3 -12 8 -18 11 -15 3 2 10 -5 17 -18 8 -15 8 -24 1 -29 -7 -5 -4 -8 7 -8 11 0 15 -4 11 -12 -5 -7 -3 -8 5 -4 8 5 14 0 18 -13 3 -12 10 -21 15 -21 5 0 7 4 4 9 -4 5 5 4 18 -2 13 -7 22 -15 20 -18 -2 -4 5 -9 16 -12 13 -3 18 -1 13 6 -3 7 3 4 14 -6 14 -12 23 -15 28 -8 3 6 11 11 16 11 6 0 8 -3 6 -7 -3 -5 386 -8 863 -8 477 0 866 3 863 8 -2 4 0 7 6 7 5 0 13 -5 16 -11 5 -7 14 -4 28 8 11 10 17 13 14 6 -5 -7 0 -9 13 -6 11 3 18 8 16 12 -2 3 7 11 20 18 13 6 22 7 18 2 -3 -5 -1 -9 4 -9 5 0 12 9 15 21 4 13 10 18 18 13 8 -4 10 -3 5 4 -4 8 0 12 11 12 11 0 14 3 7 8 -7 5 -7 14 1 29 7 13 14 20 17 18 3 -3 8 3 11 15 3 13 1 18 -6 13 -7 -3 -4 2 5 13 13 14 14 23 6 38 -6 10 -7 16 -2 13 5 -3 9 366 9 858 0 475 -3 861 -7 858 -12 -7 -9 12 4 25 9 9 7 17 -8 33 -10 13 -14 19 -7 16 7 -5 9 0 6 13 -3 12 -8 18 -11 15 -3 -2 -10 5 -17 18 -8 15 -8 24 -1 29 7 5 4 8 -7 8 -11 0 -15 4 -11 12 5 7 3 8 -5 4 -8 -5 -14 0 -18 13 -3 12 -10 21 -15 21 -5 0 -7 -4 -4 -9 4 -5 -5 -4 -18 2 -13 7 -22 15 -20 18 2 4 -5 9 -16 12 -13 3 -18 1 -13 -6 3 -7 -3 -4 -14 6 -14 12 -23 15 -28 8 -3 -6 -11 -11 -16 -11 -6 0 -8 3 -6 8 3 4 -386 7 -863 7 -477 0 -866 -3 -863 -7 6 -12 -11 -10 -23 2 -7 7 -16 4 -28 -8zm1867 -106c15 -10 31 -30 35 -45 9 -34 9 -1828 0 -1862 -4 -15 -20 -35 -35 -45 -27 -18 -65 -19 -949 -19 -740 0 -926 3 -945 13 -57 30 -54 -16 -57 937 -2 484 0 904 3 934 8 62 38 97 88 104 18 2 437 4 932 3 862 -1 901 -2 928 -20z"
android:fillColor="#000000" />
<path
android:pathData="M2335 1165c0 -556 1 -784 2 -508 2 276 2 730 0 1010 -1 279 -2 54 -2 -502z"
android:fillColor="#000000" />
<path
android:pathData="M667 3C944 1 1396 1 1672 3 1949 4 1723 5 1170 5 617 5 391 4 667 3Z"
android:fillColor="#000000" />
</group>
</vector>

最新更新