You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have been playing around with Spoon for some time and I discovered a problem with the created screenshots. They do not incorporate the elevation that is present on CardView for example. This is because of the way how Spoon creates it's screenshots.
At first I didn't know if it was related to Spoon or my views, so I copied the Spoon implementation of taking screenshots and started experimenting. This is the implementation I took:
privatestaticvoidtakeScreenshot(Filefile, finalActivityactivity) throwsIOException {
Viewview = activity.getWindow().getDecorView();
finalBitmapbitmap = Bitmap.createBitmap(view.getWidth(), view.getHeight(), ARGB_8888);
if (Looper.myLooper() == Looper.getMainLooper()) {
// On main thread already, Just Do It™.drawDecorViewToBitmap(activity, bitmap);
} else {
// On a background thread, post to main.finalCountDownLatchlatch = newCountDownLatch(1);
activity.runOnUiThread(newRunnable() {
@Overridepublicvoidrun() {
try {
drawDecorViewToBitmap(activity, bitmap);
} finally {
latch.countDown();
}
}
});
try {
latch.await();
} catch (InterruptedExceptione) {
Stringmsg = "Unable to get screenshot " + file.getAbsolutePath();
Log.e(TAG, msg, e);
thrownewRuntimeException(msg, e);
}
}
OutputStreamfos = null;
try {
fos = newBufferedOutputStream(newFileOutputStream(file));
bitmap.compress(PNG, 100/* quality */, fos);
chmodPlusR(file);
} finally {
bitmap.recycle();
if (fos != null) {
fos.close();
}
}
}
Spoon client version:
1.6.4
.Spoon runner version:
spoon-runner-1.7.1-jar-with-dependencies.jar
.I have been playing around with Spoon for some time and I discovered a problem with the created screenshots. They do not incorporate the elevation that is present on
CardView
for example. This is because of the way how Spoon creates it's screenshots.At first I didn't know if it was related to Spoon or my views, so I copied the Spoon implementation of taking screenshots and started experimenting. This is the implementation I took:
Because it was me giving odd results, I went searching for a solution and stumbled upon this post:
https://stackoverflow.com/questions/34795786/how-to-capture-screenshot-with-shadow-using-getdrawingcache
I quickly tried to make a screenshot with the following implementation, which worked as expected (it is in kotlin).
The text was updated successfully, but these errors were encountered: