What's differences between Surfaceview and TextureView?

后端 未结 4 1346
忘掉有多难
忘掉有多难 2020-12-23 13:58

I\'ve been studying Android especially View system. I have a question differences between them but there is no documents or references in my mother language. So I want to kn

4条回答
  •  自闭症患者
    2020-12-23 14:20

    In addition to other answers, this could be beneficial for novice android developers or anyone who will see this.

    In my case, using this snippet in OnCreate method helped me to find out which device can use SurfaceView

        if (
                GLES20.glGetString(GLES20.GL_RENDERER) == null ||
                        GLES20.glGetString(GLES20.GL_VENDOR) == null ||
                        GLES20.glGetString(GLES20.GL_VERSION) == null ||
                        GLES20.glGetString(GLES20.GL_EXTENSIONS) == null ||
                        GLES10.glGetString(GLES10.GL_RENDERER) == null ||
                        GLES10.glGetString(GLES10.GL_VENDOR) == null ||
                        GLES10.glGetString(GLES10.GL_VERSION) == null ||
                        GLES10.glGetString(GLES10.GL_EXTENSIONS) == null) {
            // try to use SurfaceView
        } else {
            // try to use TextureView
        }
    

    Hope it helps people who develop video player apps :)

提交回复
热议问题