title: How to convert view into Drawable
body: <p>I want to convert Android View into Drawable.</p>
  
  <p>I try below method:</p>
  
  <pre><code>View view1;
  
    view1 = getLayoutInflater().inflate(R.layout.layout1, null);
    view1.setDrawingCacheEnabled(true);
    ((TextView)(view1.findViewById(R.id.txt_number))).setText("98"); 
  
    view1.setLayoutParams(new MapView.LayoutParams(LayoutParams.WRAP_CONTENT,        LayoutParams.WRAP_CONTENT, getPoint(23.01, 72.55), MapView.LayoutParams.BOTTOM_CENTER));
              mapView.addView(overlayPin1);
  
              Log.d("view", "000");
              if(view1!=null)
              {
                  Log.d("view", "111");
                  System.out.println("view is not null.....");
                  view1.buildDrawingCache();
                  Bitmap bm = view1.getDrawingCache();
                  Log.d("view", "222");
                  try
                  {
                      Log.d("view", "333");
                      //if(bm!=null)
                      //{
                          Log.d("view", "444");
                          String dir = Environment.getExternalStorageDirectory().toString();
                          System.out.println("bm is not null.....");
                          OutputStream fos = null;
                          File file = new File(dir,"sample.JPEG");
                          fos = new FileOutputStream(file);
                          BufferedOutputStream bos = new BufferedOutputStream(fos);
                          bm.compress(Bitmap.CompressFormat.JPEG, 50, bos);
                          bos.flush();
                          bos.close();
                          Log.d("view", "555");
                      //}
                  }
                  catch(Exception e)
                  {
                      Log.d("view", "666");
                      System.out.println("Error="+e);
                      e.printStackTrace();
                  }
              }  
  </code></pre>
  
  <p>But all the time I get the null bitmap.</p>