I managed to speed up my processing noticeably. I previously stored a tile buffer in an int array. During onDraw, I used Canvas.drawBitmap(int[] ...). I found this is not as efficient as Canvas.drawBitmap(Bitmap...). So, I changed to store a tile buffer in Bitmap. Just to post my solution here so that others could benefit.
Frank On May 27, 11:40 pm, Frank <[email protected]> wrote: > Thank you very much, Dianne. > > So if I do useViewand I have to redraw it in onDraw while scrolling, > how can I make the drawing process as fast as possible? Basically, I > have a whole bunch of tile buffers available and I just need to piece > them together ontoView'sCanvas based on the scroll position. I am > currently using dramBitmap, but the scrolling is not very smooth. > > Frank > > On May 27, 3:50 pm, Dianne Hackborn <[email protected]> wrote: > > > > > > > > > You shouldn't put aSurfaceViewinside of a ScrollView or other such > > container. Since a surfaceviewis actually creating a separate window that > > is positioned along with your window and provides the surface, those kinds > > of interactions just won't work. > > > The way a scrollviewworks is that it expects to have one childview, whose > > height is potentially larger than the scrollview. If it is larger, then > > the scrollviewwill change offsets to scroll around in it. Theviewbeing > > larger in height doesn't use any more memory or such -- this is just a > > virtual coordinate space, with appropriate offsets and clipping applied by > > the scrollviewwhen it is drawn. > > > Calling setMeasuredDimension() in onMeasure() should definitely make it be > > the size you specify. Make sure you are not calling the super class > > implementation or doing your code after calling the super class, since there > > is a default implementation inViewto set the measurements. Also make sure > > you are using wrap_content for theview, not match_parent. > > > You could try looking in hierarchyviewer to see what is going on with the > >viewhierarchy. > > > On Fri, May 27, 2011 at 2:54 PM, Frank <[email protected]> wrote: > > > Hi All, > > > > I am writing an application that needs to put aViewinside a > > > ScrollView. SinceViewis used to display some content that is very > > > long, I doView.setMeasuredDimension(width, large_height) inView's > > > onMeasure() callback function. I noticed that no matter how high the > > >Viewis, its Canvas size I queried inView.onDraw() is the same with > > > that of the viewport. This is good since the memory consumption is > > > only dependent on the size of the viewport. But the downside is that I > > > have to redraw the entire Canvas manually every time onDraw() is > > > called. > > > > Instead ofView, I can useSurfaceView. However, the problem is that I > > > cannot doSurfaceView.setMeasuredDimension(width, large_height). I > > > found that the Canvas size ofSurfaceViewis the same with its virtual > > > size (not the same with the viewport asView). So the underlying > > > Bitmap takes lots of memory and my application won't even run (because > > > of out of memory). > > > > Does any of you know any solution to this problem? Thank you very > > > much. > > > > Thanks, > > > Frank > > > > -- > > > 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 > > > -- > > Dianne Hackborn > > Android framework engineer > > [email protected] > > > Note: please don't send private questions to me, as I don't have time to > > provide private support, and so won't reply to such e-mails. 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

