I want to set a background color to the surface view to my camera surface view.
I am using this for implementing the same. But this example is not complete. Can anyone please help me with some other useful link.
Thanks
use surfaceview_obj.setBackgroundColor (int color) to set background color..
to set white color as background use this code
surfaceview_obj.setBackgroundColor(0Xffffffff);
check this
There's a workaround to do this.
add a parent viewgroup for the surfaceview, set the background color to this viewgroup instead of the 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>
add the following for the SurfaceView instance;
surfaceView.setZOrderOnTop(true);
surfaceView.getHolder().setFormat(PixelFormat.TRANSLUCENT);
Now you get the background color you want and the surfaceview is tanslucent.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With