title: set image from drawable xml to google map marker
body: <p>I have this series of xml-drawables in particular drawable folders, for example in drawable-mpdi:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;bitmap
  xmlns:android="http://schemas.android.com/apk/res/android"
  android:src="@drawable/m0_48px"
  /&gt; 
  </code></pre>
  
  <p>drawable-hdpi differs only with src pointing to m0_72px and so on.</p>
  
  <p><strong>And I want to let android decide what image resolution will use in marker</strong>. If I do this in this way:</p>
  
  <pre><code>int imageRes = c.getResources().getIdentifier("drawable/m0",
                      null, c.getPackageName());
  Marker marker = m.addMarker(new MarkerOptions()
              .position(new LatLng(s.lat, s.lon))
              .icon(BitmapDescriptorFactory.fromResource(imageRes))
              .anchor(0.5f, 1f));
  </code></pre>
  
  <p>I get some resource ID in imagesRes, but BitmapDescriptorFactory won't accept this.</p>
  
  <p>If I do it in this way:</p>
  
  <pre><code>int imageRes = c.getResources().getIdentifier("drawable/m0",
                          null, c.getPackageName());
  Bitmap bitmap = BitmapFactory.decodeResource(c.getResources(), imageResource);
  
  Marker marker = m.addMarker(new MarkerOptions()
      .position(new LatLng(s.lat, s.lon))
      .icon(BitmapDescriptorFactory.fromResource(imageRes))
      .anchor(0.5f, 1f));
  </code></pre>
  
  <p>I get null in bitmap var.</p>
  
  <p>This question <a href="https://stackoverflow.com/questions/18053156/set-image-from-drawable-as-marker-in-google-map-version-2">Set Image from drawable as marker in Google Map version 2</a> and especially this comment</p>
  
  <blockquote>
    <p>Well, you can - you just need to paint it into a Canvas first
    (drawable.draw(canvas)), then dump the Canvas to a Bitmap. –  Chris
    Broadfoot</p>
  </blockquote>
  
  <p>lead me nowhere I'm not able to replicate mentioned procedure...</p>
  
  <p>Please, any help welcome!</p>