关于自定义 SurfaceView
我在主框架上充气图层,并且有一个 ScrollView
。 我想绘制一个可以在屏幕上向左、向右、向上、向下移动的大图像。 因此,我用自定义的 SurfaceView
并将 addView
添加到 ScrollView
来描述这一点, 但我想要的图像没有显示。我该如何解决这个问题?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在这种情况下,我认为没有必要使用 SurfaceView。 SurfaceViews 通常用于相机预览、视频播放等。还有用于 opengl 绘图的 GLSurfaceView。
如果您正在程序上创建要显示的大图像(例如,通过 Canvas.draw 方法),那么您可能可以简单地创建一个自定义 View 子类并覆盖 onDraw (也可能覆盖 onMeasure)。
或者,如果您要从磁盘加载大图像或将其作为资源加载,则只需使用 ImageView。
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.