glsurfaceview inside a scrollview, moving but not clipping

前端 未结 3 835
悲&欢浪女
悲&欢浪女 2020-12-21 17:59

I have a scrollview with a linear layout inside. One of the elements inside this linearlayout is a glsurfaceview.

This all works correctly and when I scroll the glsu

相关标签:
3条回答
  • 2020-12-21 18:12

    It is not about support as answered abowe. The cause of issue is that GLSurfaceView is not on the view level. In short: for you case you have GLSurfaceView at the first level, then other views with holes in views abowe GLSurfaceView (this handles by windows manager, and it dosent matter where you put GLSurfaceView on xml, it will be on first level in any case and others views on next level)

    So, what you need is to force view update, and there is work around: you should put scroll with GLSurfaceView or (RecyclerView with GLSurfaceViews) "between" two FrameLayouts. something like this:

    <?xml version="1.0" encoding="utf-8"?>
    <FrameLayout   
      xmlns:android="http://schemas.android.com/apk/res/android"
      android:layout_width="match_parent"
      android:layout_height="match_parent" >
    
         <ScrollView
            android:fillViewport="true"
            android:layout_width="match_parent"
            android:layout_height="match_parent">
    
           ---- here should be linear layout with your glView, or RecyclerView instead if required ----
         </ScrollView>
    
       --- this frame also required: ---
       <FrameLayout
          android:layout_width="match_parent"
          android:layout_height="match_parent"
          android:background="@android:color/transparent" />
    
    </FrameLayout>
    
    0 讨论(0)
  • 2020-12-21 18:19

    You may use below lines for removing over scrolling :

    glView.getHolder().setFormat(PixelFormat.TRANSLUCENT);
    glView.setZOrderOnTop(true);
    glView.setZOrderMediaOverlay(true); 
    

    And for removing black background :

    linearLayout.setBackgroundColor(context.getResources().getColor(R.color.white));
    linearLayout.addView(glView);
    

    Also add below line in your manifests file :

    android:hardwareAccelerated="true"
    
    0 讨论(0)
  • 2020-12-21 18:33

    Hosting SurfaceViews inside ScrollView (or Listview, etc.) is currently not supported.

    0 讨论(0)
提交回复
热议问题