Displaying SVG files in Android
Asked Answered
T

4

26

I want to create an app that will display position on some floor plan. Navigation is implementing via WiFi in certain way, I've done it and so now I have a problem of displaying floor plan.

It might be in some vector format, after surfing internet for some time I've decided that it must be svg file. I found some solutions, but it isn't working for me!

  1. Library svg-android

    There is opportunity to display .svg files, but only "simple" files. It works fine only for file in tutorial, but not for any other .svg file (for example, some other file, that you'll create with Inkscape).

    So, I decided, that I'll parse .svg file, make DOM from it, somehow get objects and attributes and draw it via OpenGL ES.

  2. Apache Batik

    At first glance, very good solution, but there is a problem. Android has some "native" apache libraries and when I try to do something with batik, it throws NoClassDefFoundError, because it's searching not in batik libraries, but in "native" libraries.

    Of course, we can add source code in our project, take only batik parser for .svg files and edit it in some way, but there is a lot of work, with same success we can write our own parser.

  3. Tiny Line

    There is no trial version, but if we'll see description of how it works for svg files and android, we'll see that there is only rasterization of such files and that's all.

Is there any solution better than writing own parser? Did anyone come across this problem?

Tough answered 18/7, 2012 at 6:52 Comment(2)
Another option - https://mcmap.net/q/537374/-svg-android-imageview-not-workingTransmission
An old post, but for those who are ending up here may refer tutorialkart.com/kotlin-android/… which uses AndroidSVG third party libraryIde
T
11

I would suggest using #1. Don't write your own parser. It's just going to be a huge headache.

How detailed does your floor plan have to be? android-svg supports SVG fairly well. It just doesn't have great support for filters or light sources. Your SVG isn't going to have those in them (I hope).

If you don't want to do that, look into quad trees. You can render out a huge image and break that down into a quadtree like format then only load the quads you require.

Thermometry answered 18/7, 2012 at 7:0 Comment(3)
I don't think "android-svg" exists it's either "androidsvg" or "svg-android".Recalesce
I can recommend "androidsvg" as a more complete library than "svg-android". Google code (going offline in a few months as of posting) and Bitbucket links. The license is listed in the source files and seems to be Apache 2.0.Adminicle
I found the androidsvg tweaked library by greenrobot to be better compile 'de.greenrobot:androidsvg:1.2.2-beta-1-tweaked-2'Comport
S
4

I have authored an SVG libaray for android the website is http://www.vectoroid.com

the main thing missing is SVG arc support this is currently fixed and will be in a release in the near future.

I am looking for feedback on it, as i have been working on it for about a year. So if you have any please do tell ...

Swath answered 26/9, 2012 at 17:10 Comment(1)
Thanks for your efforts for writing this library. I'd like to use your library in my app but I'm not sure whether it fits my requirements or not. I'd want to write a kinda free drawing app which saves SVG paths drawn by user and interactively need to check where currently user's finger is and execute some codes accordingly. Is it possible with your library?Churchlike
T
2

I've using yet another SVG for Android; seems it is relatively new.

GPLv3, CSS2 support, fonts, texts and spans, linear and radial gradients, SVG and SVGZ, initial filtering support, images from assets, from web and inline base64-encoded images. Fastest from all I've tried.

Of course filters support might be better, but except this it works well and even displays 20-megabytes SVG files.

Theophany answered 29/9, 2015 at 13:54 Comment(0)
P
2

Successfully tested these 2 libraries:

https://github.com/BigBadaboom/androidsvg - Apache License 2.0

https://scand.com/products/svgkit-android/ - needed tweaking to compile with modern SDK (suppress warnings, update gradle file); LGPL / commercial

androidsvg looks better so far.

Padegs answered 30/7, 2020 at 18:34 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.