title: convert view into bitmap
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/2801116/converting-a-view-to-bitmap-without-displaying-it-in-android">Converting a view to Bitmap without displaying it in Android?</a>  </p>
  </blockquote>
  
  
  
  <p>I am trying to convert the view into bitmap from following reference link</p>
  
  <p><a href="http://www.brighthub.com/mobile/google-android/articles/30676.aspx" rel="nofollow noreferrer">link text</a></p>
  
  <p>Now the problem is how can i get the bitmap that is being converted from view only. in the example author has used relativelayout.dispatchDraw(c) but this line is giving me compile time error i.e.</p>
  
  <blockquote>
    <p>The method dispatchDraw(Canvas) from
    the type ViewGroup is not visible</p>
  </blockquote>
  
  <p>Here is my code and i have written the following code inside onCreate function</p>
  
  <pre><code>    Canvas c=null;
  
      //Create Layout
      RelativeLayout relativeView ;           
      RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(
      RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.MATCH_PARENT
      );
  
      relativeView = new RelativeLayout(this);            
      relativeView.setLayoutParams(lp);
  
      //Background of Layout
      Bitmap viewBgrnd  = BitmapFactory.decodeResource(getResources(),R.drawable.bgblack);
      relativeView.setBackgroundDrawable(new BitmapDrawable(viewBgrnd));
  
      //associated with canvas 
      Bitmap returnedBitmap =               Bitmap.createBitmap(320,480,Bitmap.Config.ARGB_8888);     
      c = new Canvas(returnedBitmap);
      Paint paint = new Paint();
  
  
      //Create Imageview that holds image             
      ImageView newImage = new ImageView(this);
      Bitmap srcBitmap = BitmapFactory.decodeResource(getResources(),R.drawable.bgpink);
      newImage.setImageBitmap(srcBitmap);
  
      TextView newText = new  TextView(this);
  
      newText.setText("This is the text that its going to appear");       
  
      c.drawBitmap(viewBgrnd, 0, 0, paint);
              relativeView.layout(100, 0, 256, 256);  
      relativeView.addView(newImage);
      relativeView.addView(newText);
  
  
          // here i am getting compile time error so for timing i have replaced this line
          // with relativeView.draw(c);
  
      relativeView.dispatchDraw(c);
  </code></pre>
  
  <p>Here the returnedBitmap should contain the image of (ImageView and TextView) but this bitmap contains only bacground bitmap of relativeView i.e. bgblack</p>