Thank you very much, Dianne. So if I do use View and 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 onto View's Canvas 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 <hack...@android.com> wrote: > You shouldn't put a SurfaceView inside of a ScrollView or other such > container. Since a surface view is 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 scroll view works is that it expects to have one child view, whose > height is potentially larger than the scroll view. If it is larger, then > the scroll view will change offsets to scroll around in it. The view being > 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 scroll view when 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 in View to set the measurements. Also make sure > you are using wrap_content for the view, not match_parent. > > You could try looking in hierarchyviewer to see what is going on with the > view hierarchy. > > > > > > On Fri, May 27, 2011 at 2:54 PM, Frank <frank.android....@gmail.com> wrote: > > Hi All, > > > I am writing an application that needs to put a View inside a > > ScrollView. Since View is used to display some content that is very > > long, I do View.setMeasuredDimension(width, large_height) in View's > > onMeasure() callback function. I noticed that no matter how high the > > View is, its Canvas size I queried in View.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 of View, I can use SurfaceView. However, the problem is that I > > cannot do SurfaceView.setMeasuredDimension(width, large_height). I > > found that the Canvas size of SurfaceView is the same with its virtual > > size (not the same with the viewport as View). 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 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 > > -- > Dianne Hackborn > Android framework engineer > hack...@android.com > > 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 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