What are best practices for using SVG icons on Android?

前端 未结 12 1349
臣服心动
臣服心动 2020-12-12 11:46

I am about to create my first Android native (so not browser based) app and looking for some good practices regarding icon creating/provisioning. Since it s

12条回答
  •  遥遥无期
    2020-12-12 12:02

    I've just started using Victor, an open source library by Trello, to convert SVG files to PNG files of the various required resolutions during build time.

    PROS

    • You won't have to run a script or tool to create various PNG files every time you change or add an icon. (You do need to hit Rebuild in Android Studio when you've added a new svg file or renamed an existing one)
    • No PNG's in your source, so there's less clutter.

    CONS

    • The only downside I've seen so far is that Android Studio doesn't yet recognize generated resources in XML, so you'll get some red warnings in your XML files and you don't have autocomplete for your SVG based drawables. It builds fine though, and this issue should be fixed in a future version of Android Studio.

    If you use SVG generated by http://materialdesignicons.com/ be sure to either download the whole file, or copy from the 'SVG File'-tab when choosing 'View SVG'

提交回复
热议问题