Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Having issue on Real Device using vector image in android. SVG-android

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?

like image 638
Ivan Podhornyi Avatar asked Aug 21 '13 11:08

Ivan Podhornyi


People also ask

Is SVG supported in Android?

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.

Can I use SVG as background image in Android?

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.

What is the default location of the vector icons imported through Android Studio?

@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.

Do you need SVG on Android?

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.

How to import a vector graphic into an Android app?

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:

Why can't I use vector drawables with Android Studio?

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.

Does megatronking/SVG-Android support SVG images for Android?

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: 简体中文.


1 Answers

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.

like image 118
Paul LeBeau Avatar answered Oct 23 '22 15:10

Paul LeBeau