矢量Pathdata中的任何方法都可以通过编程方式转换吗?

时间:2017-10-18 07:22:06

标签: android svg android-drawable android-vectordrawable

在vector pathData xml中就像这样

  <path android:fillColor="#8fff"
  android:pathData="M20.5,9.5
                    c-1.955,0,-3.83,1.268,-4.5,3
                    c-0.67,-1.732,-2.547,-3,-4.5,-3
                    C8.957,9.5,7,11.432,7,14
                    c0,3.53,3.793,6.257,9,11.5
                    c5.207,-5.242,9,-7.97,9,-11.5
                    C25,11.432,23.043,9.5,20.5,9.5z" />

如果我有路径数据作为字符串,是否可以转换图像?

String pathdata ="M20.5,9.5
                    c-1.955,0,-3.83,1.268,-4.5,3
                    c-0.67,-1.732,-2.547,-3,-4.5,-3
                    C8.957,9.5,7,11.432,7,14
                    c0,3.53,3.793,6.257,9,11.5
                    c5.207,-5.242,9,-7.97,9,-11.5
                    C25,11.432,23.043,9.5,20.5,9.5z";

 imageView.setImageDrawable(pathdataDrawable)

如何以编程方式将pathdata转换为pathdataDrawable。我搜索很多方式是谷歌,仍然找不到正确的解决方案。

0 个答案:

没有答案