Using Hardware acceleration in different fragments

68 views Asked by At

I use single activity approach in my app and I have 2 fragments. In first fagment I have GLSurfaceView and it dosen't work correctly, when hardwareAccelerated="false". In second fragment I have TextureView and TextureView or a subclass can only be used with hardware acceleration enabled. So when hardwareAccelerated="false" first fragment with GLSurfaceView dosen't work, and when hardwareAccelerated="true" second fragment with TextureView dosen't work. How can I fix this?

I tryed set in AndroidManifest and then change it to true for textureView only using setLayerType in onViewCreated fun in SecondFragment, but I still have error: TextureView or a subclass can only be used with hardware acceleration enabled.

override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
        binding.textureView.setLayerType(View.LAYER_TYPE_HARDWARE, null)
        super.onViewCreated(view, savedInstanceState)
    }

I also tryed setFlags in MainActivity when I move from one fragment to another. Still same error

window.setFlags(
        WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED,
        WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED
)

0

There are 0 answers