Android Studio Vector asset always could not generate a preview

旧时模样 提交于 2019-12-24 11:57:30

问题


I want to use vector asset in android studio to generate svg xml file, I convert my png to svg in this web site
but when I use this svg file in vector asset to generate xml file, I get following error message


It display "could not generate a preview"
How can I fix it?


回答1:


I've never had any luck with those convert sites. You're better off using photo tools to create an SVG. Make sure to follow the SVG guidelines from Android listed here




回答2:


Most of the complaints on this topic are due to people trying to convert SVGs that use features of the SVG standard that are not supported by VectorDrawables. And the SVG to VectorDrawable converter in AndroidStudio only supports those limited features. It doesn't really give much feedback when it encounters things it doesn't support.

Some of the online converters try a bit harder. You might have better success with them. Otherwise you may have to simplify your SVGs to get them to work.

If you need to display SVGs images that are more complicated than VectorDrawables can handle, then you can always consider using an SVG rendering library for Android. IMHO the best one is AndroidSVG (disclaimer I wrote that one).




回答3:


There are some cases when your actual .svg file name contains some capital letters. Just rename them in all small letters and try to upload it.

For instance: If actual .svg image name is mySavedimage.svg {here 'S' is capital which is against norms of android assets}. SO if you rename that file to my_saved_image.svg then this will work as a charm.

hope it helps.




回答4:


The error is in the converter. The SVG file might not be proper.




回答5:


You need to use photo editor tools like Photoshop or Gimp.



来源:https://stackoverflow.com/questions/54384676/android-studio-vector-asset-always-could-not-generate-a-preview

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!