Note that there are some explanatory texts on larger screens.

plurals
  1. PONot being able to take proper screenshots
    primarykey
    data
    text
    <p>I am currently working on an app which will take screenshot and then email them as an attachment. I want a screenshot of the following "LinearLayout"...</p> <p>However, something very weird is happening when this function is called. Instead of taking a screenshot of the whole layout, just about 1/10th of the screenshot is taken (like just the half of the first column). Can anyone please suggest what is wrong with the code here?</p> <pre><code> &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/tableview" android:layout_width="fill_parent" android:layout_height="fill_parent" android:weightSum="1" android:orientation="vertical" &gt; &lt;TableLayout android:padding="5dp" android:layout_width="match_parent" android:id="@+id/TransactionLog" android:layout_height="wrap_content"&gt; &lt;TableRow android:layout_height="wrap_content"&gt; &lt;TextView android:layout_margin="4dip" android:layout_weight="1" android:padding="10dip" android:layout_height="wrap_content" android:text="Date" android:layout_width="0dip" android:id="@+id/dateLabel" /&gt; &lt;TextView android:layout_margin="4dip" android:layout_weight="1" android:padding="10dip" android:layout_height="wrap_content" android:text="Details" android:layout_width="0dip" android:id="@+id/detailsLabel" /&gt; &lt;TextView android:layout_margin="4dip" android:layout_weight="1" android:padding="10dip" android:layout_height="wrap_content" android:text="Debit" android:layout_width="0dip" android:id="@+id/debitLabel" /&gt; &lt;TextView android:layout_margin="4dip" android:layout_weight="1" android:padding="10dip" android:layout_height="wrap_content" android:text="Credit" android:layout_width="0dip" android:id="@+id/creditLabel" /&gt; &lt;TextView android:layout_margin="4dip" android:layout_weight="1" android:padding="10dip" android:layout_height="wrap_content" android:text="Balance" android:layout_width="0dip" android:id="@+id/balanceLabel" /&gt; &lt;/TableRow&gt; &lt;TableRow android:layout_height="wrap_content"&gt; &lt;TextView android:layout_margin="4dip" android:layout_weight="1" android:padding="10dip" android:layout_height="wrap_content" android:text="5 October 2011" android:layout_width="0dip" android:id="@+id/date1" /&gt; &lt;TextView android:layout_margin="4dip" android:layout_weight="1" android:padding="10dip" android:layout_height="wrap_content" android:text="CoCoa Shop" android:layout_width="0dip" android:id="@+id/details1" /&gt; &lt;TextView android:layout_margin="4dip" android:layout_weight="1" android:padding="10dip" android:layout_height="wrap_content" android:text="123.53" android:layout_width="0dip" android:id="@+id/debit1" /&gt; &lt;TextView android:layout_margin="4dip" android:layout_weight="1" android:padding="10dip" android:layout_height="wrap_content" android:text="0.00" android:layout_width="0dip" android:id="@+id/credit1" /&gt; &lt;TextView android:layout_margin="4dip" android:layout_weight="1" android:padding="10dip" android:layout_height="wrap_content" android:text="6729.32" android:layout_width="0dip" android:id="@+id/balance1" /&gt; &lt;/TableRow&gt; &lt;TableRow android:layout_height="wrap_content"&gt; &lt;TextView android:layout_margin="4dip" android:layout_weight="1" android:padding="10dip" android:layout_height="wrap_content" android:text="4 October 2011" android:layout_width="0dip" android:id="@+id/date1" /&gt; &lt;TextView android:layout_margin="4dip" android:layout_weight="1" android:padding="10dip" android:layout_height="wrap_content" android:text="Best Sell" android:layout_width="0dip" android:id="@+id/details1" /&gt; &lt;TextView android:layout_margin="4dip" android:layout_weight="1" android:padding="10dip" android:layout_height="wrap_content" android:text="900.53" android:layout_width="0dip" android:id="@+id/debit1" /&gt; &lt;TextView android:layout_margin="4dip" android:layout_weight="1" android:padding="10dip" android:layout_height="wrap_content" android:text="0.00" android:layout_width="0dip" android:id="@+id/credit1" /&gt; &lt;TextView android:layout_margin="4dip" android:layout_weight="1" android:padding="10dip" android:layout_height="wrap_content" android:text="6729.32" android:layout_width="0dip" android:id="@+id/balance1" /&gt; &lt;/TableRow&gt; &lt;TableRow android:layout_height="wrap_content"&gt; &lt;TextView android:layout_margin="4dip" android:layout_weight="1" android:padding="10dip" android:layout_height="wrap_content" android:text="4 October 2011" android:layout_width="0dip" android:id="@+id/date1" /&gt; &lt;TextView android:layout_margin="4dip" android:layout_weight="1" android:padding="10dip" android:layout_height="wrap_content" android:text="Deposit" android:layout_width="0dip" android:id="@+id/details1" /&gt; &lt;TextView android:layout_margin="4dip" android:layout_weight="1" android:padding="10dip" android:layout_height="wrap_content" android:text="0.00" android:layout_width="0dip" android:id="@+id/debit1" /&gt; &lt;TextView android:layout_margin="4dip" android:layout_weight="1" android:padding="10dip" android:layout_height="wrap_content" android:text="9500.00" android:layout_width="0dip" android:id="@+id/credit1" /&gt; &lt;TextView android:layout_margin="4dip" android:layout_weight="1" android:padding="10dip" android:layout_height="wrap_content" android:text="6729.32" android:layout_width="0dip" android:id="@+id/balance1" /&gt; &lt;/TableRow&gt; &lt;/TableLayout&gt; &lt;/LinearLayout&gt; </code></pre> <p>And here is the JAVA function which is supposed to take the screenshot and save it to a file called "log" in the SD Card.</p> <pre><code> private void getScreen() { View content = findViewById(R.id.tableview); content.setDrawingCacheEnabled(true); content.measure(MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED), MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED)); content.layout(0, 0, content.getMeasuredWidth(), content.getMeasuredHeight()); content.buildDrawingCache(true); Bitmap bitmap = Bitmap.createBitmap(content.getDrawingCache()); content.setDrawingCacheEnabled(false); // clear drawing cache File file = new File( Environment.getExternalStorageDirectory() + "/log.png"); try { file.createNewFile(); FileOutputStream ostream = new FileOutputStream(file); bitmap.compress(CompressFormat.PNG, 100, ostream); ostream.close(); } catch (Exception e) { e.printStackTrace(); } } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload