In recent google IO 2015, google announced that the new Android Studio 1.3/ new gradle plugin will have support for importing and SVG file and the build system will generate the assets for different device densities (hdpi, xhdpi, xxhdpi etc):
http://robovm.com/google-io-summary-whats-new-in-android-development-tools/ https://www.youtube.com/watch?v=f7ihSQ44WO0&feature=youtu.be&t=2m46s
Unfortunately there doesnt seem to be more information about how to achieve that. Does any one have any more details about it?
There is some mention of it in : Android: Using SVG in res leads to error: "The file name must end with .xml or .png"
and I tried to create a hello world app and places an svg file (renamed it to xml in the drawable folder). it compiled and installed on the device, but crashed during execution saying svg is not a vlaid tag. suppose the original file needs more conversion.
Use Adobe Photoshop to convert SVG images to PNG images. Get lossless compression, preserve image resolution, and lower your file size by converting from SVG to PNG. Use Photoshop for a fast way to turn large file formats into smaller, easier-to-use graphic types.
svg file, right click on it and click on the context menu item 'Save SVG as PNG. Lets you click on the extension icon or right click on an . svg file and choose Save SVG as PNG.
Android Studio includes a tool called Vector Asset Studio that helps you add material icons and import Scalable Vector Graphic (SVG) and Adobe Photoshop Document (PSD) files into your project as vector drawable resources.
In addition, they support animation while PNG doesn't, and raster file types that support animation like GIF, APNG, and WebP all have their issues. For simple graphics that may require animation and are guaranteed to scale well on any screen size, use SVG.
To add a new vector asset right click on your drawable folder in Android Studio and choose New > Vector asset. Please note that you need Gradle 1.4 or newer to use vector assets with projects with a build target lower than 21. In this case Gradle will convert the vector images to PNGs at build time.
The current beta version of Gradle 1.4 has some issues with opening keystores when releasing an apk, so before importing a lot of vector images, try to release your app first (this is only my personal experience with Gradle 1.4.0-beta6, Gradle will report a tampered keystore, e.g. see here)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With