Using GLSurfaceView class with android xml layouts

后端 未结 2 2058
旧时难觅i
旧时难觅i 2021-02-04 09:04

I want to make use of the android xml layouts. I have put a glSurfaceView in a frame layout to use in conjunction with a linear layout like so...



        
2条回答
  •  旧巷少年郎
    2021-02-04 09:54

    Just reference your own class (with full packagename) in the xml, the same way you reference android.opengl.GLSurfaceView. Make sure that your subclass implements the proper constructor, and passes the context & attributes to the parent:

    public MyGLSurfaceView(Context context, AttributeSet attrs)
    {
       super(context, attrs);
    

    Then you can fetch it using findViewById:

    MySurfaceView glSurfaceView = 
                 (MySurfaceView)findViewById(R.id.surfaceviewclass);
    

    That should do the trick.

提交回复
热议问题