ScrollView sv is bigger than its rootView, calling sv.getDrawingCache() causes crash?
<p>Here is my simple layout:</p>

<pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content" &gt;
&lt;LinearLayout
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical" &gt;
    &lt;TextView
        android:id="@+id/my_long_textview"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:text="@string/long_text_str" /&gt;
    &lt;Button
        android:id="@+id/capture_screen"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:onClick="captureScreen"
        android:text="Capture Screen" /&gt;
&lt;/LinearLayout&gt;
&lt;/ScrollView&gt;
</code></pre>

<p>the following code in captureScreen() function crashes the app:</p>

<pre><code>TextView tv = (TextView) findViewById(R.id.my_long_textview);
tv.setDrawingCacheEnabled(true);
tv.buildDrawingCache(); // comment out this line makes no difference
bitmap = Bitmap.createBitmap(tv.getDrawingCache()); // this is line 31 in stack trace
tv.setDrawingCacheEnabled(false);
</code></pre>

<p>This code works but I really like to capture the entire TextView:</p>

<pre><code> View rv = v.getRootView();
 rv.setDrawingCacheEnabled(true);
 bitmap = Bitmap.createBitmap(rv.getDrawingCache());
 rv.setDrawingCacheEnabled(false);
</code></pre>

<p>Stack Trace is as follows:</p>

<pre><code>04-21 00:17:08.023: E/AndroidRuntime(27472): java.lang.IllegalStateException: Could not execute method of the activity
04-21 00:17:08.023: E/AndroidRuntime(27472):    at android.view.View$1.onClick(View.java:2072)
04-21 00:17:08.023: E/AndroidRuntime(27472):    at android.view.View.performClick(View.java:2408)
04-21 00:17:08.023: E/AndroidRuntime(27472):    at android.view.View$PerformClick.run(View.java:8816)
04-21 00:17:08.023: E/AndroidRuntime(27472):    at android.os.Handler.handleCallback(Handler.java:587)
04-21 00:17:08.023: E/AndroidRuntime(27472):    at android.os.Handler.dispatchMessage(Handler.java:92)
04-21 00:17:08.023: E/AndroidRuntime(27472):    at android.os.Looper.loop(Looper.java:123)
04-21 00:17:08.023: E/AndroidRuntime(27472):    at android.app.ActivityThread.main(ActivityThread.java:4627)
04-21 00:17:08.023: E/AndroidRuntime(27472):    at java.lang.reflect.Method.invokeNative(Native Method)
04-21 00:17:08.023: E/AndroidRuntime(27472):    at java.lang.reflect.Method.invoke(Method.java:521)
04-21 00:17:08.023: E/AndroidRuntime(27472):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
04-21 00:17:08.023: E/AndroidRuntime(27472):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
04-21 00:17:08.023: E/AndroidRuntime(27472):    at dalvik.system.NativeStart.main(Native Method)
04-21 00:17:08.023: E/AndroidRuntime(27472): Caused by: java.lang.reflect.InvocationTargetException
04-21 00:17:08.023: E/AndroidRuntime(27472):    at com.gtgg.ui.TextViewAct.captureScreen(TextViewAct.java:31)
04-21 00:17:08.023: E/AndroidRuntime(27472):    at java.lang.reflect.Method.invokeNative(Native Method)
04-21 00:17:08.023: E/AndroidRuntime(27472):    at java.lang.reflect.Method.invoke(Method.java:521)
04-21 00:17:08.023: E/AndroidRuntime(27472):    at android.view.View$1.onClick(View.java:2067)
04-21 00:17:08.023: E/AndroidRuntime(27472):    ... 11 more
04-21 00:17:08.023: E/AndroidRuntime(27472): Caused by: java.lang.NullPointerException
04-21 00:17:08.023: E/AndroidRuntime(27472):    at android.graphics.Bitmap.createBitmap(Bitmap.java:358)
04-21 00:17:08.023: E/AndroidRuntime(27472):    ... 15 more
</code></pre>

<p>Is there a way to save the big text view into a bitmap, even though it's bigger than the rootView?</p>

<p>Thanks a lot!</p>
