I'm putting the screenshot function on the calendar, but the photo is not coming out as it should.
Butusingthenativeandroidfunctioncomesoutcorrect
Here's some code snippet:
View v1 = getActivity().findViewById(R.id.ScrollcalendarView);
v1.setDrawingCacheEnabled(true);
ScrollView z = (ScrollView) getActivity().findViewById(R.id.ScrollcalendarView);
int totalHeight = z.getChildAt(0).getHeight();
int totalWidth = z.getChildAt(0).getWidth();
v1.layout(0, 0, totalWidth, totalHeight);
Bitmap bitmap = Bitmap.createBitmap(v1.getDrawingCache());
v1.setDrawingCacheEnabled(false);
File imageFile = new File(mPath);
FileOutputStream outputStream = new FileOutputStream(imageFile);
int quality = 100;
bitmap.compress(Bitmap.CompressFormat.JPEG, quality, outputStream);
outputStream.flush();
outputStream.close();
openScreenshot(imageFile);
} catch (Throwable e) {
// Several error may come out with file handling or OOM
e.printStackTrace();
}
}
Does anyone have an idea what it can be?