Use a jar executable to create a Drawable class to display a SVG on Android.

Overview

SVG2Drawable

Use a jar executable to create a Drawable class to display a SVG on Android.

This is a standalone library, not a Runtime Android library. You need to use it BEFORE your Android compilation (and only once per SVG file).

Why?

I want to use a scalable image format.

A SVG sounds really good but it's a bit long to load (mainly the time to parse the XML) and I didn't find any library that support the Hardware acceleration.

How does it work?

My main goal is to have a Drawable class:

  • Made a fork of the svg-android library.
  • Replaced any instructions to create a Picture to collect them into a Logger.
  • Print this Logger.
  • Save it to a Drawable java class.

How to use it?

You can read the code but I'm not proud of it. I started to do a POC for a basic usage and now I need to transform the code to make it more readable and robust.

You can simply use the jar provided into this repo by specify:

  • the SVG file
  • the package where you want to put the Drawable
  • the drawable name

You can also specify the output of the script to create a file. By adding "> filename.java".

java -jar svg_converter.jar example.svg com.skocken.svg.example.drawable ExampleDrawable > ExampleDrawable.java

Now, copy this "ExampleDrawable.java" into your Android project, into the package "com.skocken.svg.example.drawable" (from this example), and add it to your ImageView into your code with:

imageview.setImageDrawable(new ExampleDrawable());

diagram

License

Contributing

If you found a SVG with a problem, you can open an issue. Please, if possible, let me know if this same SVG work with the library svg-android.

Please fork this repository and contribute back using pull requests.

Any contributions, large or small, major features, bug fixes, additional language translations, unit/integration tests are welcomed and appreciated but will be thoroughly reviewed and discussed.

You might also like...
Custom shaped android imageview components
Custom shaped android imageview components

Shape Image View Provides a set of custom shaped android imageview components, and a framework to define more shapes. Implements both shader and bitma

Android widget for cropping and rotating an image.
Android widget for cropping and rotating an image.

Cropper The Cropper is an image cropping tool. It provides a way to set an image in XML and programmatically, and displays a resizable crop window on

A simple image cropping library for Android.
A simple image cropping library for Android.

SimpleCropView The SimpleCropView is an image cropping library for Android. It simplifies your code for cropping image and provides an easily customiz

Customizable Android full screen image viewer for Fresco library supporting
Customizable Android full screen image viewer for Fresco library supporting "pinch to zoom" and "swipe to dismiss" gestures. Made by Stfalcon

This project is no longer supported. If you're able to switch from Fresco to any other library that works with the Android's ImageView, please migrate

Dali is an image blur library for Android. It contains several modules for static blurring, live blurring and animations.
Dali is an image blur library for Android. It contains several modules for static blurring, live blurring and animations.

Dali Dali is an image blur library for Android. It is easy to use, fast and extensible. Dali contains several modules for either static blurring, live

An image resizing library for Android
An image resizing library for Android

Resizer Inspired by zetbaitsu's Compressor, Resizer is a lightweight and easy-to-use Android library for image scaling. It allows you to resize an ima

Photo picker library for android. Let's you pick photos directly from files, or navigate to camera or gallery.
Photo picker library for android. Let's you pick photos directly from files, or navigate to camera or gallery.

ChiliPhotoPicker Made with ❤️ by Chili Labs. Library made without DataBinding, RxJava and image loading libraries, to give you opportunity to use it w

Simple android image popup Library
Simple android image popup Library

Android Image Popup Show image as a popup on a click event or any event. Simply set the image as drawable and thats it!!!. And also you can set width,

Image loading library for Android

Image Loader Image loader library for Android. Deprecated. See Glide. Features Image transformations Automatic memory and storage caching Ability to l

Comments
  • NullPointerException

    NullPointerException

    Exported Illustrator SVGs throws Nullpointer Exception.

    <?xml version="1.0" encoding="utf-8"?>
    <!-- Generator: Adobe Illustrator 18.1.1, SVG Export Plug-In . SVG Version: 6.00 Build 0)  -->
    <svg version="1.1" id="Ebene_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
         viewBox="0 0 1000 1000" enable-background="new 0 0 1000 1000" xml:space="preserve">
    

    SVGHandler throws Nullpointer at line 273

    width = (int) Math.ceil(getFloatAttr("width", atts));
    

    SVG width and hight is set by the viewBox attribute.

    opened by pfaffenrodt 3
Owner
Stan Kocken
Stan Kocken
SVG to Android VectorDrawable XML resource file

svg2android [Deprecated - use official Vector Asset Studio directly from Android Studio] Convert SVG to Android VectorDrawable XML resource file. Extr

INLOOPX 1.7k Dec 29, 2022
SVG rendering library for Android

AndroidSVG AndroidSVG is a SVG parser and renderer for Android. It has almost complete support for the static visual elements of the SVG 1.1 and SVG 1

Paul LeBeau 1.1k Dec 28, 2022
An implementation of a gif decoder written 100% in Kotlin, plus an associated Drawable for Android

An implementation of a gif decoder written 100% in Kotlin, plus an associated Drawable for Android

Benoît Vermont 41 Nov 19, 2022
Phimp.me Android Phimp.me is an Android image editor app

Phimp.me Android Phimp.me is an Android image editor app that aims to replace proprietary photographing and image apps on smart phones. It offers feat

FOSSASIA 2.6k Jan 6, 2023
Opencv Android SDK application for Deep Neural Networks to run on Android.

This application allows you to deploy deep nets in Android environment using OpenCV Android SDK. With OpenCV, images are taken from the camera on your phone, and then these images are passed through the neural network and visualized on the front side. In this application, we will search for faces in the images taken and draw the found faces on the screen.

Ahmet Furkan DEMIR 10 Nov 1, 2022
Android filters based on OpenGL (idea from GPUImage for iOS)

GPUImage for Android Idea from: iOS GPUImage framework Goal is to have something as similar to GPUImage as possible. Vertex and fragment shaders are e

CATS Open Source Softwares 8.6k Dec 28, 2022
Android library project for cropping images

I guess people are just cropping out all the sadness An Android library project that provides a simple image cropping Activity, based on code from AOS

Jamie McDonald 4.5k Jan 7, 2023
Custom view for circular images in Android while maintaining the best draw performance

CircularImageView Custom view for circular images in Android while maintaining the best draw performance Usage To make a circular ImageView, add this

Pkmmte Xeleon 1.2k Dec 28, 2022
some android image filters

android-image-filter some android image filters in some filter, I use NDK to implement to make it more efficient Setup Install Android NDK and properl

RagnarokStack 643 Dec 27, 2022
An android image compression library.

Compressor Compressor is a lightweight and powerful android image compression library. Compressor will allow you to compress large photos into smaller

Zetra 6.7k Dec 31, 2022