samedi 8 mars 2014

[Q] How to take a screenshot of vertical and horizontal layout in Android topic




I have an app which displays a table/matrix of a Math exercise. This table can be really big so I use vertical and horizontal layout. I need to take a screenshot of the whole layout, but it only saves screenshot of visible screen. What should I do?

This is my layout

Code:


<ScrollView xmlns:android="...I cant post link because of spam filter..."
    android:id="@+id/myScrollView"
    xmlns:tools="..."
    android:layout_width="fill_parent"
    android:layout_height="wrap_content" >

    <HorizontalScrollView
        android:id="@+id/myHorizontalScrollView"
        android:layout_width="wrap_content"
        android:layout_height="fill_parent" >

        <TableLayout
            android:id="@+id/myTableLayout"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:stretchColumns="1" />

    </HorizontalScrollView>
</ScrollView>


This is how I take screenshot but only visible screen, not whole layout

Code:


View v1 = getWindow().getDecorView().getRootView();
v1.setDrawingCacheEnabled(true);
Bitmap myBitmap = v1.getDrawingCache();       
saveBitmap(myBitmap); // saves to storage







Aucun commentaire:

Enregistrer un commentaire