title: Android - Glide 4.0.0-RC0: how to set tint color for ImageView after successfully loading SVG
body: <p>I followed this sample: <a href="https://github.com/bumptech/glide/tree/master/samples/svg/src/main/java/com/bumptech/glide/samples/svg" rel="nofollow noreferrer">https://github.com/bumptech/glide/tree/master/samples/svg/src/main/java/com/bumptech/glide/samples/svg</a></p>
  
  <p>After successfully loading SVG file with Glide 4.0.0-RC0, i want to set tint color for ImageView, but setColorFilter NOT WORKING</p>
  
  <p>My source:</p>
  
  <pre><code>package com.example.quangson.glidesvg;
  
  import static com.bumptech.glide.load.resource.drawable.DrawableTransitionOptions.withCrossFade;
  
  import android.content.ContentResolver;
  import android.graphics.PorterDuff;
  import android.graphics.drawable.PictureDrawable;
  import android.net.Uri;
  import android.os.Bundle;
  import android.support.v7.app.AppCompatActivity;
  import android.widget.ImageView;
  import com.bumptech.glide.RequestBuilder;
  import com.example.quangson.glidesvg.glide.GlideApp;
  import com.example.quangson.glidesvg.glide.SvgSoftwareLayerSetter;
  
  public class MainActivity extends AppCompatActivity {
  
      private static final String TAG = "SVGActivity";
      private ImageView imageViewSVG;
      private ImageView imageViewPNG;
      private RequestBuilder&lt;PictureDrawable&gt; requestBuilder;
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
  
          imageViewSVG = (ImageView) findViewById(R.id.svg_image_view1);
          imageViewPNG = (ImageView) findViewById(R.id.svg_image_view2);
  
          imageViewPNG.setImageResource(R.drawable.image_mylogo);
  
          requestBuilder = GlideApp.with(this)
                  .as(PictureDrawable.class)
                  .error(R.drawable.image_error)
                  .transition(withCrossFade())
                  .listener(new SvgSoftwareLayerSetter());
          Uri uri = Uri.parse(ContentResolver.SCHEME_ANDROID_RESOURCE + "://" + getPackageName() + "/"  + R.raw.android_toy_h);
          requestBuilder.load(uri).into(imageViewSVG);
  
          imageViewSVG.setColorFilter(getResources().getColor(R.color.colorAccent), PorterDuff.Mode.SRC_IN);
          imageViewPNG.setColorFilter(getResources().getColor(R.color.colorAccent), PorterDuff.Mode.SRC_IN);
      }
  }
  </code></pre>
  
  <p>In my source: </p>
  
  <p>I loaded PNG image (from res/drawable) into imageViewPNG and setColorFilter for imageViewPNG ⇒ WORKING</p>
  
  <p>I loaded SVG image (from res/raw) into imageViewSVG and setColorFilter for imageViewSVG ⇒ NOT WORKING (Loaded SVG file successfully but can't setColorFilter)</p>
  
  <p>Please help me set tint color for imageViewSVG.</p>
  
  <hr>
  
  <p>I tried edit like below code to making SvgDrawableTranscoder that generates a BitmapDrawable (and will setColorFilter after that), but it's not working, help me?</p>
  
  <pre><code>package com.sonzero.chibiz.glide;
  
  import android.graphics.Bitmap;
  import android.graphics.Canvas;
  import android.graphics.Picture;
  import android.graphics.drawable.BitmapDrawable;
  import android.graphics.drawable.Drawable;
  import android.graphics.drawable.PictureDrawable;
  
  import com.bumptech.glide.load.engine.Resource;
  import com.bumptech.glide.load.resource.SimpleResource;
  import com.bumptech.glide.load.resource.transcode.ResourceTranscoder;
  import com.caverock.androidsvg.SVG;
  
  /**
   * Convert the {@link SVG}'s internal representation to an Android-compatible one
   * ({@link Picture}).
   */
  public class SvgDrawableTranscoder implements ResourceTranscoder&lt;SVG, BitmapDrawable&gt; {
      @Override
      public Resource&lt;BitmapDrawable&gt; transcode(Resource&lt;SVG&gt; toTranscode) {
          SVG svg = toTranscode.get();
          Picture picture = svg.renderToPicture();
          PictureDrawable drawable = new PictureDrawable(picture);
          Bitmap bitmap = asBitmap(drawable);
          BitmapDrawable mDrawable = new BitmapDrawable(bitmap);
          return new SimpleResource&lt;BitmapDrawable&gt;(mDrawable);
      }
  
      public Bitmap asBitmap(PictureDrawable pd) {
          Bitmap bitmap = Bitmap.createBitmap(pd.getIntrinsicWidth(),pd.getIntrinsicHeight(), Bitmap.Config.ARGB_8888);
          Canvas canvas = new Canvas(bitmap);
          canvas.drawPicture(pd.getPicture());
          return bitmap;
      }
  }
  </code></pre>