最佳答案
有一个解决方法可以做到这一点。
为surfaceview添加一个parent viewgroup,设置背景色为这个viewgroup而不是surfaceview;
<FrameLayout android:layout_width="match_parent" android:layout_height="match_parent" android:background="@android:color/holo_blue_dark"> <com.example.surfacetest.MySurface android:id="@+id/surface" android:layout_width="match_parent" android:layout_height="match_parent" /> </FrameLayout>
为 SurfaceView 实例添加以下内容;
surfaceView.setZOrderOnTop(true); surfaceView.getHolder().setFormat(PixelFormat.TRANSLUCENT);
现在你得到了你想要的背景颜色,表面 View 是半透明的。
关于android - 设置表面 View 的背景颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15277140/