I'm currently working on a project which needs to display a dialog with a grayout (black/white) background. To achieve this I'm taking a screenshot and of the whole app, place this screenshot on the background of the fullscreen dialog and put an ColorFilter on it to have it grayed out.
This works perfect for the first time, but if I scroll in the underlaying content and request the dialog again, it shows just the same background as the one before.
I use the code:
Bitmap bitmap;
View rootView = getActivity().getWindow().getDecorView().findViewById(android.R.id.content);
rootView.setDrawingCacheEnabled(true);
bitmap = Bitmap.createBitmap(rootView.getDrawingCache());
rootView.setDrawingCacheEnabled(false);
imageView.setImageBitmap(bitmap);
In other words, the getDrawingCache() always returns the same screenshot of the app.