user2012
user2012

Reputation: 337

Android: how to add scroll for surfaceview?

I'm drawing some graphics and i would like to add scroll to it. But with the surface view how to add the scroll programatically ?

Upvotes: 1

Views: 2355

Answers (1)

Pal Szasz
Pal Szasz

Reputation: 3225

SurfaceView is a very special component, it's not easy to mix it with other components. The main reason is due to how it works: when you use a SurfaceView, a new window will be created (by default behind the activity) and all the rendering in the SurfaceView will go to that window. SurfaceView will also "draw a hole" in the activity, so the window behind it will be visible.

SurfaceView needs to synchronize the window position with it's position, which is not done perfectly. For example if you put a SurfaceView inside something which can scroll, the window won't scroll (at least it didn't the last time I tried, around Froyo time).

Please provide some more information about what you are trying to do. If you just want to create a custom component, it's easier to just subclass View and override onDraw(Canvas).

Upvotes: 3

Related Questions