天天看點

android surfaceview 背景顔色,android – 設定Surface View的背景顔色

有一個解決方法來做到這一點.

>為surfaceview添加父視圖組,将背景顔色設定為此視圖組而不是surfaceview;

android:layout_width="match_parent"

android:layout_height="match_parent"

android:background="@android:color/holo_blue_dark">

android:id="@+id/surface"

android:layout_width="match_parent"

android:layout_height="match_parent" />

>為SurfaceView執行個體添加以下内容;

surfaceView.setZOrderOnTop(true);

surfaceView.getHolder().setFormat(PixelFormat.TRANSLUCENT);

現在你得到你想要的背景顔色,而surfaceview是tanslucent.