Android get a bitmap of a view before drawing?
<p>I am looking to take a view hierarchy and turn it into a Bitmap. Using the <a href="http://developer.android.com/reference/android/view/View.html#getDrawingCache%28boolean%29" rel="nofollow">view.getDrawingCache()</a> does exactly what I want it to do but will not work if I try that before the view is drawn. Is there another function that will do the same thing but before it is actually drawn? I would like to create the view and turn it into a bitmap to display and discard the actual view. If there is a way to force the view to be drawn that might work as well. Any ideas?</p>

<p>I found this in a previous post:</p>

<pre><code>    public static Bitmap loadBitmapFromView(View v) {
         Bitmap b = Bitmap.createBitmap( v.getLayoutParams().width, v.getLayoutParams().height, Bitmap.Config.ARGB_8888);                
         Canvas c = new Canvas(b);
         v.layout(0, 0, v.getLayoutParams().width, v.getLayoutParams().height);
         v.draw(c);
         return b;
    }
</code></pre>

<p>This looks promising but when I use it all I get is a semi transparent black box.</p>
