title: Android: Generate image from dynamic view
body: <p>I want to generate chart dynamically, and save the chart as image for later use in the application,
  Need not to display the chart on the screen, 
  I can generate the chart using <code>AFreeChart</code> Library, The chart is actually a sub view of <code>View</code> class,
  I want to get bitmap from the view using the following code, but the method <code>getDrawingCache()</code> always returns null,</p>
  
  <pre><code>    // Retrieve the chart generated using AFreeChart Library
      // PressureChart is a sub view of View class
       PressureChart mView = new PressureChart(this);
  
       mView.setDrawingCacheEnabled(true);
       mView.buildDrawingCache(true);
       Bitmap b = Bitmap.createBitmap(mView.getDrawingCache());
       mView.setDrawingCacheEnabled(false); // clear drawing cache
  </code></pre>