There is absolutely *no need* to do all of this. All you have to do is call setDrawingCacheEnabled(true) on your View (or ViewGroup) and the framework will do the rest. This will work on 1.5 and 1.6.
On Thu, May 6, 2010 at 7:22 AM, [email protected] <[email protected]> wrote: > Hi list, > > I am trying to cache my viewgroup to a bitmap and blit this to screen > instead of calling dispatchDraw on the group while scrolling for > performance reasons. This works quite well on 1.5, but has ugly > scaling artefacts on 1.6 and newer for high density screens. Because > of my 1.5 compatibility I can't find a way to set the density of my > cached bitmap. > > Here is the relevant code from my ViewGroup subclass: > > �...@override > public void dispatchDraw (Canvas canvas) { > if (active) { // Draw the real viewgroup if we aren't > scrolling > super.dispatchDraw(canvas); > } else { // otherwise create a cached copy if necessary and > draw > this > if (idleView == null) { // create canvas and bitmap if > not done > already > idleView = Bitmap.createBitmap(getWidth(), > getHeight(), > Bitmap.Config.ARGB_8888); > idleCanvas = new Canvas(idleView); > idleViewValid = false; > } > if (!idleViewValid) { // Draw onto the canvas > super.dispatchDraw(idleCanvas); > idleViewValid = true; > } > // Then render this bitmap to screen > canvas.drawBitmap(idleView, matrix, paint); > } > } > > I tried the same with getDrawingCache and had the same problem :( > > I'd be glad for any help. > > Best regards, > > Kevin > > -- > You received this message because you are subscribed to the Google > Groups "Android Developers" group. > To post to this group, send email to [email protected] > To unsubscribe from this group, send email to > [email protected] > For more options, visit this group at > http://groups.google.com/group/android-developers?hl=en > -- Romain Guy Android framework engineer [email protected] Note: please don't send private questions to me, as I don't have time to provide private support. All such questions should be posted on public forums, where I and others can see and answer them -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en

