android - How can we tile a vector image? -


with support library supporting vector images, i'm trying switch vector images as can in app. issue i'm running seems impossible repeat them.

with bitmap images following xml used:

<bitmap     xmlns:android="http://schemas.android.com/apk/res/android"     android:src="@drawable/repeat_me"     android:tilemode="repeat"     /> 

this not work, vector images can not used in bitmaps: https://code.google.com/p/android/issues/detail?id=187566

is there other way tile/repeat vector images?

thanks @pskink made drawable tiles drawable: https://gist.github.com/9ffbdf01478e36194f8f

this has set in code, can not used xml:

public class tilingdrawable extends android.support.v7.graphics.drawable.drawablewrapper {      private boolean callbackenabled = true;      public tilingdrawable(drawable drawable) {         super(drawable);     }      @override     public void draw(canvas canvas) {         callbackenabled = false;         rect bounds = getbounds();         drawable wrappeddrawable = getwrappeddrawable();          int width = wrappeddrawable.getintrinsicwidth();         int height = wrappeddrawable.getintrinsicheight();         (int x = bounds.left; x < bounds.right + width - 1; x+= width) {             (int y = bounds.top; y < bounds.bottom + height - 1; y += height) {                 wrappeddrawable.setbounds(x, y, x + width, y + height);                 wrappeddrawable.draw(canvas);             }         }         callbackenabled = true;     }      @override     protected void onboundschange(rect bounds) {     }      /**      * {@inheritdoc}      */     public void invalidatedrawable(drawable who) {         if (callbackenabled) {             super.invalidatedrawable(who);         }     }      /**      * {@inheritdoc}      */     public void scheduledrawable(drawable who, runnable what, long when) {         if (callbackenabled) {             super.scheduledrawable(who, what, when);         }     }      /**      * {@inheritdoc}      */     public void unscheduledrawable(drawable who, runnable what) {         if (callbackenabled) {             super.unscheduledrawable(who, what);         }     } } 

Comments

Popular posts from this blog

java - Run spring boot application error: Cannot instantiate interface org.springframework.context.ApplicationListener -

reactjs - React router and this.props.children - how to pass state to this.props.children -

Excel VBA "Microsoft Windows Common Controls 6.0 (SP6)" Location Changes -