在Android Studio中制作“发光”矢量图像

时间:2017-09-04 17:23:52

标签: android xml svg vector

我正在尝试为我的应用制作带有“发光”效果的矢量图像(更像是这样的东西:

this

我做了我的矢量:

vector

在Inkscape中复制,将选区移到底部并增加模糊。我使用此工具将此.svg文件转换为xml(“http:/a-student.github.io/SvgToVectorDrawableConverter.Web/”我删除了一个斜杠,抱歉我的声誉太低了)。但是当我复制这个时:

<?xml version="1.0" encoding="utf-8"?>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:viewportWidth="178.9086"
android:viewportHeight="223.5271"
android:width="633.92791757485dp"
android:height="792.02492552128dp">
<group
    android:translateX="-58.56168"
    android:translateY="159.8559">
    <group
        android:scaleX="15.01775"
        android:scaleY="15.01775"
        android:translateX="-820.9032"
        android:translateY="-892.5264">
        <path
            android:pathData="M70.474839 62.368916q-0.530545 0.231511 -0.964627 0.434082 -0.424436 0.202572 -1.118967 0.424436 -0.588423 0.183279 -1.282954 0.308681 -0.684885 0.135047 -1.514464 0.135047 -1.562695 0 -2.845649 -0.434082 -1.273307 -0.443728 -2.218641 -1.379416 -0.926042 -0.916395 -1.44694 -2.32475 -0.520899 -1.418002 -0.520899 -3.289378 0 -1.774913 0.501606 -3.173622 0.501606 -1.398709 1.44694 -2.363335 0.916396 -0.935688 2.208995 -1.427648 1.302247 -0.49196 2.884234 -0.49196 1.157553 0 2.305458 0.279742 1.157553 0.279742 2.565908 0.98392l0 2.266872 -0.144694 0q-1.186491 -0.993565 -2.35369 -1.44694 -1.167198 -0.453374 -2.498383 -0.453374 -1.090028 0 -1.967839 0.356912 -0.868164 0.347265 -1.553049 1.090028 -0.665592 0.72347 -1.041797 1.832791 -0.366558 1.099674 -0.366558 2.546614 0 1.514464 0.405143 2.604493 0.41479 1.090028 1.06109 1.774913 0.675239 0.713824 1.572342 1.061089 0.906749 0.33762 1.909961 0.33762 1.379416 0 2.585199 -0.472667 1.205784 -0.472668 2.257227 -1.418002l0.135048 0z"
            android:fillColor="#ffffff" />
    </group>
    <group
        android:scaleX="15.01775"
        android:scaleY="15.01775"
        android:translateX="-820.9032"
        android:translateY="-892.5264">
        <path
            android:pathData="M70.474839 62.368916q-0.530545 0.231511 -0.964627 0.434082 -0.424436 0.202572 -1.118967 0.424436 -0.588423 0.183279 -1.282954 0.308681 -0.684885 0.135047 -1.514464 0.135047 -1.562695 0 -2.845649 -0.434082 -1.273307 -0.443728 -2.218641 -1.379416 -0.926042 -0.916395 -1.44694 -2.32475 -0.520899 -1.418002 -0.520899 -3.289378 0 -1.774913 0.501606 -3.173622 0.501606 -1.398709 1.44694 -2.363335 0.916396 -0.935688 2.208995 -1.427648 1.302247 -0.49196 2.884234 -0.49196 1.157553 0 2.305458 0.279742 1.157553 0.279742 2.565908 0.98392l0 2.266872 -0.144694 0q-1.186491 -0.993565 -2.35369 -1.44694 -1.167198 -0.453374 -2.498383 -0.453374 -1.090028 0 -1.967839 0.356912 -0.868164 0.347265 -1.553049 1.090028 -0.665592 0.72347 -1.041797 1.832791 -0.366558 1.099674 -0.366558 2.546614 0 1.514464 0.405143 2.604493 0.41479 1.090028 1.06109 1.774913 0.675239 0.713824 1.572342 1.061089 0.906749 0.33762 1.909961 0.33762 1.379416 0 2.585199 -0.472667 1.205784 -0.472668 2.257227 -1.418002l0.135048 0z"
            android:fillColor="#ffffff" />
    </group>
</group>
</vector>

到drawable中的.xml文件中阴影是不可见的。这是普通的矢量。我的问题是:这样可以制作发光的矢量吗?完全有可能吗?

1 个答案:

答案 0 :(得分:1)

VectorDrawable并不支持SVG的<filter>元素,而这正是Inkscape用来模糊发光的原因。

您必须使用其他方法。例如。第二层View s并使用其中一种技术模糊后方模糊视图。例如:

  1. How to blur a view or layout in android?
  2. How to Blur A View