i working on android application, i tried taking the screenshot of root layout where a text view, video view and relative layout as root view, i'm facing a problem that video is showing as black colored only text view is visible in the screenshot, my goal is to capture root layout along with text on the video clip. please help
<RelativeLayout
android:id="@+id/root_layout"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<VideoView
android:id="@+id/video_player"
android:layout_width="match_parent"
android:layout_height="match_parent"
/>
<TextView
android:id="@+id/text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="SAMPLE"
android:layout_centerInParent="true" />
</RelativeLayout>
My screenshot code:
Capturing the above root layout which id is 'root_layout'
public static class Screenshot {
public static Bitmap takescreenshot(View v) {
v.setDrawingCacheEnabled( true );
v.buildDrawingCache( true );
Bitmap b = Bitmap.createBitmap( v.getDrawingCache() );
v.setDrawingCacheEnabled( false );
return b;
}
public static Bitmap takescreenshotOfRootView(View v) {
return takescreenshot( v.getRootView() );
}
}