将ImageView实现为SurfaceView

我有一个小问题……

是否可以在SurfaceView实现ImageView ,或在SurfaceView创建ImageView

如果是这样,有人会指出我正确的方向如何做到这一点。

我在使用TextView的代码中执行此操作,但您可以使用ImageView更改文本视图。

我的TextView是一个顶部的小条,因此更改参数。

  params = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.FILL_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT); LinearLayout layout = new LinearLayout(this); layout.setOrientation(LinearLayout.VERTICAL); TextView tv = new TextView(this); ourSurfaceView = new SurfGame(this); testbox = new LinearLayout.LayoutParams(widthx,heighty/30); layout.addView(tv,testbox); layout.addView(ourSurfaceView,params); setContentView(layout); 

不,您无法将子Views添加到SurfaceView

您可以将ImageViewSurfaceView放在其他容器中,并且一些容器( RelativeLayoutFrameLayout )允许后来的子项浮动在早期子项的顶部(Z轴排序)。 因此,您可以通过这种方式在SurfaceView中提供ImageView的视觉外观。