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

Related tags

Tools SVG2Drawable
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...
An easy to use translation / localization api written in Kotlin that can be used with Java and Kotlin

KTranslate KTranslate is an easy to use TranslationAPI written in Kotlin, with currently 26 supported languages. It is very easy to use in Kotlin and

A simple utility to remove unused resources in your Android app to lower the size of the APK. It's based on the Android lint tool output.

android-resource-remover android-resource-remover is utility that removes unused resources reported by Android Lint from your project. The goal is to

This is a Android Studio/ IntelliJ IDEA plugin to localize your Android app, translate your string resources automactically.
This is a Android Studio/ IntelliJ IDEA plugin to localize your Android app, translate your string resources automactically.

#Android Localizationer This is a Android Studio/ IntelliJ IDEA plugin to localize your Android app, translate your string resources automactically. T

A cli tool that helps signing and zip aligning single or multiple Android application packages (APKs) with either debug or provided release certificates. It supports v1, v2 and v3 Android signing scheme has an embedded debug keystore and auto verifies after signing. Automated-build-android-app-with-github-action - CI/CD Automated Build Android App Bundle / APK / Signed With Github Action
Automated-build-android-app-with-github-action - CI/CD Automated Build Android App Bundle / APK / Signed With Github Action

Automated Build Android With Using Github Action Project Github Action Script Us

proguard resource for Android by wechat team

AndResGuard Read this in other languages: English, 简体中文. AndResGuard is a tooling for reducing your apk size, it works like the ProGuard for Java sour

A super fast build tool for Android, an alternative to Instant Run
A super fast build tool for Android, an alternative to Instant Run

Freeline Freeline is a super fast build tool for Android and an alternative to Instant Run. Caching reusable class files and resource indices, it enab

Command-line tool to count per-package methods in Android .dex files

dex-method-counts Simple tool to output per-package method counts in an Android DEX executable grouped by package, to aid in getting under the 65,536

View Inspection Toolbar for Android Development
View Inspection Toolbar for Android Development

View Inspector Plugin View inspection toolbar for android development. Features Boundary show outlines show margins show paddings Layer Scalpel featur

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
• Lead Architect @Dashlane • Conference Organizer androidmakers.fr • Co-founder sesterce.io
Stan Kocken
Tool for create complex morphing animations using VectorDrawables (allows morphing between any pair of SVG images)

VectAlign VectAlign (a.k.a. VectorDrawableAlign) is a developer's tool which automagically aligns two VectorDrawable "pathData" strings (or SVG images

Stefano Bonetta 2k Dec 29, 2022
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
Android Studio's Vector Drawable conversion tool in convenient packaging.

Vector Drawable Tool This repository is simply a repackaging of the vector drawable tool from the Android Studio source code. The included Gradle file

Ryan Harter 55 Sep 26, 2022
Remote script to create a maven compatible release of an android library (aar)

release-android-library ?? Deprecated ?? This script is deprecated in favour of: novoda/bintray-release Remote script to create a maven compatible rel

Paul Blundell 144 Dec 13, 2022
Create GIFs from Android devices (pronounced "gif cap")

gifcap A shell script to record GIFs from your Android devices A picture is worth 1,000 words - and, when prototyping animations, recording visual gli

Outlook 207 Nov 26, 2022
A tool to install components of the Android SDK into a Maven repository or repository manager to use with the Android Maven Plugin, Gradle and other tools.

Maven Android SDK Deployer Original author including numerous fixes and changes: Manfred Moser [email protected] at simpligility technologies i

simpligility 1.4k Dec 27, 2022
A tool to install components of the Android SDK into a Maven repository or repository manager to use with the Android Maven Plugin, Gradle and other tools.

Maven Android SDK Deployer Original author including numerous fixes and changes: Manfred Moser [email protected] at simpligility technologies i

simpligility 1.4k Dec 27, 2022
Use an expanded notification as a makeshift Android log output console

NotificationLog Use an expanded notification as a makeshift Android log output console. https://vine.co/v/bFxhUAVjvrY The design goals of this project

Jeff Gilfelt 162 Nov 15, 2022
A library which will save you a lot of time from writing the same intent creation code. it consist of many intent creation codes like Share, Contacts, Email and etc, which you can easily use.

Android-Intent-Library A library which will save you a lot of time from writing the same intent creation code. it consist of many intent creation code

Next 67 Aug 24, 2022