Search code examples
androidsurfaceview

About Customized SurfaceView


I inflate layer on the main frame and there is a ScrollView. I want to draw a large image that can move left, right, top, and down on the screen. So, I described this with a SurfaceView that I customized and addView to ScrollView, but the Image that I want doesn't show. How can I solve this problem?


Solution

  • I don't see a need to use a SurfaceView in this case. SurfaceViews are typically used for things like Camera preview, Video playback. And there's GLSurfaceView for opengl drawing.

    If you are procedurally creating the large image that you want to display, for example, via Canvas.draw methods, then you can probably simple create a custom View subclass and override onDraw (and possibly onMeasure).

    Or, if you are loading a large image from disk or as a resource, just use an ImageView.