Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>EDIT : after seeing OP's comment</p> <p>You dont need to think about new activities at all.. Say you are in Activity right now.. Layout A is the main layout for the activity, Layout B and C are two child layouts inside Layout A. Like this,</p> <pre><code> Layout A -&gt; Parent | -------Layout B | -------Layout C </code></pre> <p>Now if you want to take screenshot of C only</p> <p>1) in onCreate() of activity</p> <pre><code> LinearLayout myCLayout = (LinearLayout)this.findViewbyId(R.id.my_c_layout); ViewTreeObserver vto = myCLayout.getViewTreeObserver(); vto.addOnGlobalLayoutListener(new OnGlobalLayoutListener() { @Override public void onGlobalLayout() { //fully drawn, no need of listener anymore myCLayout.getViewTreeObserver().removeGlobalOnLayoutListener(this); getDrawingBitmap(); } }); </code></pre> <p>where getDrawingBitmap() is a function..to take your screenshot..</p> <pre><code>public void getDrawingBitmap(){ LinearLayout myCLayout = (LinearLayout)this.findViewbyId(R.id.my_c_layout); Bitmap b = myCLayout.getDrawingCache(); File file = saveBitmapAsFile(b); } </code></pre> <p><strong>EDIT: For ScrollView</strong> </p> <p>I never tried it.. But I think you can do this..</p> <p>1) first override scrollView, and override onMeasure function..</p> <pre><code>public class MyScrollView extends ScrollView{ public MyScrollView(Context context, AttributeSet attrs) { super(context, attrs); } @Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec){ super.onMeasure(widthMeasureSpec, yourFullScrollViewHeight)); } } </code></pre> <p>and use MyScrollView in your layout.. here yourFullScrollViewHeight is the height of all scrollView content you need to take screenshot of.. I never tried this.. But it might work..</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload