如何包装SurfaceView的内容?

Cap*_*ono 0 android surfaceview

我有在之后建模的surfaceView类,我用6位图填充它.有没有办法将surfaceView包裹在位图周围,而不是覆盖整个屏幕.

我在我的xml文件中尝试了这个:

<LinearLayout
   xmlns:android="http://schemas.android.com/apk/res/android"
   android:layout_width="fill_parent"
   android:layout_height="fill_parent"
   android:orientation="horizontal">

    <com.android.customclasses.Panel
        android:layout_height="wrap_content"
        android:layout_width="wrap_content">
    </com.android.customclasses.Panel>

</LinearLayout>
Run Code Online (Sandbox Code Playgroud)

但这不起作用.它只是填补了父母.

谢谢.

Mat*_*lis 6

我不认为SurfaceView有一个"wrap_content"的概念(除了可能将其解释为"fill_parent").您必须onMeasure在自定义类中覆盖PanelsetMeasuredDimension使用适当的大小调用.

如果您考虑这一点,则有意义:您的位图不在SurfaceView视图层次结构中.它们只是由图形命令绘制到SurfaceView具有预定大小的图形命令.