SurfaceView background, how to make surfaceview transparent

180 views Asked by At

i'm newbie. I have a application that show 3d model with surfaceview, but i just want show shape of model without background of surfaceview like below picture. How do i reach it ? Thank you.' enter image description here

I try surfaceView.setZOrderOnTop(true),surfaceView.holder.setFormat(PixelFormat.TRANSPARENT) but not working !.

2

There are 2 answers

1
Abolfazl Abbasi On

Find view by id Or call this code directly on the SurfaceView object:

SurfaceView sfvTrack = (SurfaceView)findViewById(R.id.sfvTrack);
sfvTrack.setZOrderOnTop(true);    // necessary
SurfaceHolder sfhTrackHolder = sfvTrack.getHolder();
sfhTrackHolder.setFormat(PixelFormat.TRANSPARENT);

check this link

0
goldensoju On

I cannot tell you what the "official" way is to do this, but for me what works is:

surfaceView.holder.setFormat(PixelFormat.TRANSLUCENT)
view.blendMode = View.BlendMode.TRANSLUCENT
scene.skybox = null

renderer.clearOptions = renderer.clearOptions.apply {
    clear = true
}

As references:

  1. https://github.com/google/filament/issues/3048
  2. https://github.com/google/filament/discussions/6746