I’m having a `SurfaceView` like this. It’s seems l...
# compose
t
I’m having a
SurfaceView
like this. It’s seems like
Modifier.alpha
do not have any affect. The view is a video frame rendered by
MediaCodec
so every time the surface is destroyed I release the
MediaCode
so I don’t want it to be destroyed and recreated unless i’m done with it. How can I hide it on condition?
Copy code
AndroidView(
    factory = {
        view.holder.addCallback(surfaceCallback)
        view
    },
    modifier = Modifier
        .alpha(if (condition) 1f else 0f)
        .matchParentSize(),
)
s
SurfaceView
is weird one because it does not really draw on regular canvas, that's why alpha has no effect. I wonder if setting
SurfaceView
to
View.INVISIBLE
will have any effect here?
c
Maybe track your SurfaceView separately, manage its lifecycle on your own, and conditionally show the AndroidView
t
Setting to
View.INVISIBLE
resulted in the underlying surface recreated which I don’t want….
Changing to
TextureView
solved my problem. Thanks guys