title: How to make an image of a complete scrolling view in android
body: <p>How to take screenshot of a complete scrolling view in android?
  I found a lot of questions in stackoverflow but nothing solved my problem.</p>
  
  <pre><code>private void SaveImage(Bitmap finalBitmap) {
  
      String root = Environment.getExternalStorageDirectory().toString();
      File myDir = new File(root + "/saved_images");
      myDir.mkdirs();
      Random generator = new Random();
      int n = 10000;
      n = generator.nextInt(n);
      String fname = "Image-"+ n +".jpg";
      File file = new File (myDir, fname);
      if (file.exists ()) file.delete ();
      try {
          FileOutputStream out = new FileOutputStream(file);
          finalBitmap.compress(Bitmap.CompressFormat.JPEG, 90, out);
          out.flush();
          out.close();
  
      } catch (Exception e) {
          e.printStackTrace();
      }
  }
  
  public static Bitmap loadBitmapFromView(View v, int width, int height) {
      Bitmap b = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
      Canvas c = new Canvas(b);
      v.layout(0, 0, v.getLayoutParams().width, v.getLayoutParams().height);
      v.draw(c);
      return b;
  }
  </code></pre>
  
  <p>This is the code am finally used. it's giving active screen's image with other area as dark.
  When using this
  <a href="https://stackoverflow.com/questions/31229354/android-make-screenshot-of-entire-layout">android make screenshot of entire layout</a></p>
  
  <h1>xml layout file content</h1>
  
  <pre><code>&lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
      android:id="@+id/rootofall"
      android:layout_height="match_parent" android:paddingLeft="@dimen/activity_horizontal_margin"
      android:paddingRight="@dimen/activity_horizontal_margin"
      android:paddingTop="@dimen/activity_vertical_margin"
      android:background="#ffffff"
      android:paddingBottom="@dimen/activity_vertical_margin" tools:context=".MainActivity"&gt;
  
  
  
      &lt;Button
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:text="New Button"
          android:id="@+id/button"
          android:layout_alignParentTop="true"
          android:layout_centerHorizontal="true" /&gt;
      &lt;ScrollView
          android:layout_below="@+id/button"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:id="@+id/scrollView"
          &gt;
      &lt;TextView android:text="@string/alotofdata"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_centerHorizontal="true"
          android:layout_below="@+id/button"
          android:id="@+id/textView" /&gt;
  
      &lt;/ScrollView&gt;
  &lt;/RelativeLayout&gt;
  </code></pre>