I am trying to understand which this code which works perfectly for capturing almost any view except if there is a ScrollView in the framelayout, in this case there is a slight issue with the top and bottom areas where scrollview fades its contents. There is some corruption occurring.
public class FrameLayoutWithOfflineBitmap extends FrameLayout { private Bitmap mOfflineBitmap; private Canvas mOfflineCanvas; public FrameLayoutWithOfflineBitmap(Context context) { super(context); } @Override public void onSizeChanged(int w, int h, int oldw, int oldh) { // just in case we already had the bitmap allocated before if(mOfflineBitmap != null) { mOfflineBitmap.recycle(); } mOfflineBitmap = Bitmap.createBitmap(w, h, Bitmap.Config.RGB_565); mOfflineCanvas = new Canvas(); mOfflineCanvas.setBitmap(mOfflineBitmap); } @Override public void dispatchDraw(Canvas canvas) { // draw to our offline bitmap super.dispatchDraw(mOfflineCanvas); // now draw our offline bitmap to the system canvas canvas.drawBitmap(mOfflineBitmap, 0, 0, null); } public Bitmap getScreenSnapshot() { return mOfflineBitmap; } } I understand there are other ways to capture the view such as using the View's drawing cache, but I am not interested in this method. Can someone explain to me what is going on here and if there is way to address this issue? Basically I am trying to get access to a snapshot of a view as quick as possible. My idea is that the view is already drawn onto the screen, we should be able to get access to this without having to force another redundant redraw of the view. I am also very keen to understand the flaw with the above code in terms of the scrollview. Thanks. -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en