Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Vector graphics in Android

I'm working on an application that displays someone else's database of images. The images they have are all vector graphics and can be converted to any format, however keeping them in a vector format is good because users will probably want to zoom in closely.

The question is, is there a built-in way to display a vector graphic in Android? The format doesn't matter - we can convert. The current format we're considering is PDF, but given that there's no native PDF support, I'd have to do something pretty complex just to get it working (for example, integrating poppler into my app via the NDK). The alternative is to just convert the vector graphics into a simpler format (JPG, GIF) but I'd rather avoid that.

like image 252
Dan Lew Avatar asked Oct 25 '10 14:10

Dan Lew


People also ask

What is a vector in Android?

A VectorDrawable is a vector graphic defined in an XML file as a set of points, lines, and curves along with its associated color information. The major advantage of using a vector drawable is image scalability.

Why do we use vector images in Android?

Using vector drawables instead of bitmaps reduces the size of your APK because the same file can be resized for different screen densities without loss of image quality.

Can we use SVG in Android?

1. You need to convert SVG to XML to use in an Android project. 1.1 You can do this with Android SVG to VectorDrawable, but it does not support all the features of SVG, like some gradients.


1 Answers

Check out svg-android - it's a relatively new library and it only supports SVG Basic, but it's the library used to draw Androidify. There are examples on the homepage on how to get a Drawable from an SVG which sems to be what you're looking for.

like image 181
Matt Hall Avatar answered Sep 22 '22 04:09

Matt Hall