Draw inflated view directly with canvas
<p>I want to inflate a view and draw it on the canvas.I tried the following:</p>

<pre><code>Bitmap view_converted_to_bitmap = Bitmap.createBitmap(WIDTH,HEIGHT, Bitmap.Config.ARGB_8888);
Canvas c = new Canvas(view_converted_to_bitmap);
RelativeLayout relativeLayout = new RelativeLayout(getApplicationContext());
TextView textView = new TextView(getApplicationContext());          textView.setText("content");
textView.setVisibility(View.VISIBLE);
textView.setTextColor(Color.BLACK); 
relativeLayout.addView(textView);
relativeLayout.setBackgroundColor(Color.WHITE);         
relativeLayout.draw(c);
</code></pre>

<p>With the above code i am only able to see the parent i.e, relative layout and the textview is not showing up. I am getting a blank white screen.</p>

<p>And for the below logic, i am able to view the textview but the clarity is not good. screenshot.</p>

<pre><code>Bitmap b = Bitmap.createBitmap(WIDTH,HEIGHT, Bitmap.Config.ARGB_8888);
Canvas c = new Canvas(b);
TextView textView = new TextView(getApplicationContext());          textView.setText("content");
textView.setVisibility(View.VISIBLE);
textView.setTextColor(Color.BLACK);
textView.setDrawingCacheEnabled(true);
textView.measure(MeasureSpec.makeMeasureSpec(c.getWidth(), MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(c.getHeight(), MeasureSpec.EXACTLY));
textView.layout(0, 0, textView.getMeasuredWidth(), textView.getMeasuredHeight());                   
c.drawBitmap(textView.getDrawingCache(), 85, 10, new Paint());
textView.setDrawingCacheEnabled(false);
</code></pre>

<p>ACtually i need to implement page curl animation for my layouts. I am using code from  <a href="https://github.com/harism/android_page_curl/" rel="nofollow">https://github.com/harism/android_page_curl/</a> for it. But it is for bitmaps. But I want to apply it for layouts. I tried to inflate layout and tried to draw using myinflatedview.draw(canvas) , but the child elements are not showing up.</p>

<pre><code>LayoutInflater factory = LayoutInflater.from(getApplicationContext());
View view = factory.inflate(R.layout.page1, null);
view.draw(canvas);
</code></pre>

<p>In page curl project the view to be displayed on the pages with curl effect, is copied into a bitmap as in the below code.</p>

<pre><code>  int W = bitmap.getWidth();
  int H = bitmap.getHeight();
  Bitmap  mBitmap = Bitmap.createBitmap(W, H, bitmap.getConfig());
                Canvas c = new Canvas(mBitmap);
                c.drawBitmap(view_converted_to_bitmap, 0, 0, null);
</code></pre>

<p>The issue is i am not able to draw view with its child elements directly on canvas. </p>

<p>Any help is much appreciated.</p>

<p>Thanks in advance.</p>
