I use svg-android.jar
from https://github.com/pents90/svg-android
at its work fine but only on emulator devices in eclipse. Agrrrr. On real devices it just empty imageView
on screen. here is my code:
SVG svg = SVGParser.getSVGFromResource(getResources(), R.raw.test); Drawable drawable = svg.createPictureDrawable(); imgView.setImageDrawable(drawable);
any suggestion?
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.
Browser support. Using SVG as background-image has its own special set of browser support, but it's essentially the same as using SVG as img. The only problem browsers are IE 8 and down and Android 2.3 and down.
@Apurva its not always true.In new version of android studio if you import a launcher icon via image asset then it will go in res/mipmap instead.
No SVG For You. Before Android API version 21 (Lollipop), vector image representation had to be done manually or through the use of various third party libraries working with Scalable Vector Graphics (SVG). SVG, the default vector image representation format for many platforms has been developed by the World Wide Web Consortium (W3C) since 1999.
In the Android view of the Project window, right-click the res folder and select New > Vector Asset. Vector Asset Studio appears. Continue with Importing a Vector Graphic. Vector Asset Studio helps you to import a vector graphics file into your app project. Follow one of the following procedures:
Android 4.4 (API level 20) and lower doesn't support vector drawables. If your minimum API level is set at one of these API levels, you have two options when using Vector Asset Studio: generate Portable Network Graphic (PNG) files (the default) or use the Support Library.
GitHub - MegatronKing/SVG-Android: support svg images for android 4.0+, more powerful than IconFont and Vector. This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository. Loading status checks… Failed to load latest commit information. switch language: 简体中文.
On newer devices that have hardware rendering turned on by default, you need to explicitly turn on software rendering.
imgView.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
I suspect this is probably your problem.
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