title: what is the difference between setImageDrawable and setImageResource when using vector drawable?
body: <p>I have an ImageView and vector image with a gradient tag in it. I tried displaying the image with several methods and it produced varying results in Android 21.
  I have set <code>vectorDrawables.useSupportLibrary = true</code> in my project.</p>
  <ul>
  <li><p>Using <strong>setImageResource</strong>(), vector image displayed successfully</p>
  <pre><code>image.setImageResource(R.drawable.xarisanv2_img_success_payment)`
  </code></pre>
  </li>
  <li><p>Using <strong>setImageDrawable</strong>(<strong>AppCompatResources</strong>.getDrawable(), vector image displayed successfully</p>
  <pre><code>image.setImageDrawable(AppCompatResources.getDrawable(context, R.drawable.xarisanv2_img_success_payment))
  </code></pre>
  </li>
  <li><p>Using <strong>setImageDrawable</strong>(<strong>ContextCompat</strong>.getDrawable(xxxx)), app <strong>crashed</strong>.</p>
  <pre><code>image.setImageDrawable(ContextCompat.getDrawable(context, R.drawable.xarisanv2_img_success_payment))
  </code></pre>
  <p><a href="https://i.stack.imgur.com/cYajg.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/cYajg.png" alt="enter image description here" /></a></p>
  </li>
  </ul>
  <p>Could Someone explain what happening behind this? Especially about how  setImageResource can handle vector image with gradient tag.</p>