0

I want to take a screenshot of an activity which is having a scrolview. I am able to take a screenshot that contains only the visible part. Is there a way to take a more complete screenshot of the scrollview so as invisible parts are also included?

Please I need help on this, I have been stuck on it from days.

I've already tried some ways/solutions provided in related questions from the site but none of them worked for me.

Here is the layout I use:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/layout"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_margin="16dp"
android:gravity="center"
android:orientation="vertical">


<Button
    android:id="@+id/capture_screen_shot"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Take ScreenShot" />


<ScrollView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:id="@+id/sc">


    <LinearLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/m">

        <TextView
    android:id="@+id/textView"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="@string/Data" />

    </LinearLayout>


</ScrollView>


</LinearLayout>

Help me please :)

Thanasis Petsas
  • 4,378
  • 5
  • 31
  • 57
  • check if [this](http://stackoverflow.com/questions/17189809/is-it-possible-to-take-a-screenshot-of-a-view-without-showing-the-view) helps – Mehran Zamani Mar 05 '17 at 12:35
  • In your searching did you see [Is it possible to take a screenshot of a view, without showing the view?](http://stackoverflow.com/questions/17189809/is-it-possible-to-take-a-screenshot-of-a-view-without-showing-the-view)? – Mark Fitzgerald Mar 06 '17 at 05:19
  • changed the title and the language used to make the question more correct and easy to read. – Thanasis Petsas Mar 08 '17 at 22:53

2 Answers2

0

I hope this is work for you.. source here.

This is not technically a android screenshot code. but this code is to convert the whole layout view into bitmap

Bitmap bitmap = getBitmapFromView(scrollview, scrollview.getChildAt(0).getHeight(), scrollview.getChildAt(0).getWidth());

//create bitmap from the ScrollView 
private Bitmap getBitmapFromView(View view, int height, int width) {
    Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
    Canvas canvas = new Canvas(bitmap);
    Drawable bgDrawable = view.getBackground();
    if (bgDrawable != null)
        bgDrawable.draw(canvas);
    else
        canvas.drawColor(Color.WHITE);
    view.draw(canvas);
    return bitmap;
}
ZeroOne
  • 8,996
  • 4
  • 27
  • 45
-1

You're likley going to need something third party as I don't believe Android has this as a built in functionality.

Check this article out: http://phandroid.com/2016/07/13/scrolling-screenshots-android/

Pasted important parts:

Download and install Stitch & Share from Google Play

Using your device’s unique button combination, capture the first screenshot

Scroll down within the app, keeping a small portion of what was in the first screenshot visible and capture the next screenshot

Repeat the previous step until you have captured everything you want to appear within the screenshot

Swipe down on your notification panel and tap the Stitch & Share notification

Tap the green arrow icon in the bottom right corner to save or share your screenshot

BR89
  • 716
  • 1
  • 6
  • 23