title: convert ImageView to Drawable for canvas
body: <p>I have an ImageView created programmatically. I want to get the entire imageView as a drawable. When I do as follows, I get null back</p>
  
  <pre><code>private Drawable getDrawable(Data data) {
      ImageView image = new ImageView(context);
      image.setBackground(data.getColor());
      image.setImageDrawable(data.getIcon());
      return image.getDrawable();
  }
  </code></pre>
  
  <p>Now, I also suspect that my method would only return the drawable portion of the imageView, without the background.</p>
  
  <p>How do I get the entire ImageView as a drawable?</p>
  
  <p><strong>UPDATE:</strong></p>
  
  <p>The following still does not work:</p>
  
  <pre><code>private Drawable getDrawable(Data data) {
      ImageView image = new ImageView(context);
      image.setBackground(data.getColor());
      image.setImageDrawable(data.getIcon());
      image.setDrawingCacheEnabled(true);
      image.buildDrawingCache();
      Drawable drawable = new BitmapDrawable(context.getResources(), image.getDrawingCache());
      image.setDrawingCacheEnabled(false);
      return drawable;
  }
  </code></pre>