开发者

glsurfaceview inside a scrollview, moving but not clipping

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 glsurfaceview moves up and down however when the glsurfaceview reaches the top or bottom of where it should of the scrollview where it should be clipped it is not and is continued outsid开发者_如何学编程e of the scrollview. This screenshot should make it clearer:

glsurfaceview inside a scrollview, moving but not clipping

Don't think it's completly nessecary but here is my layout.xml:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" 
android:layout_height="wrap_content" 
android:orientation="vertical"
android:padding="6dip"
>
<ScrollView
android:layout_width="fill_parent" 
android:layout_height="wrap_content" 
>
    <LinearLayout
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:orientation="vertical"
    >
        <LinearLayout
        android:layout_width="fill_parent" 
        android:layout_height="wrap_content" 
        android:orientation="horizontal"
        >
            <LinearLayout
            android:layout_width="fill_parent" 
            android:layout_height="wrap_content" 
            android:orientation="vertical"
            android:layout_weight="1"
            >
            <!-- LOTS OF SEEKBARS/TEXTVIEWS -->
            </LinearLayout>
            <LinearLayout
                android:layout_width="fill_parent" 
                android:layout_height="wrap_content" 
                android:layout_weight="1.4"
                android:layout_marginRight="10dip"
                android:layout_marginLeft="10dip"
                android:orientation="horizontal" >
                <android.opengl.GLSurfaceView android:id="@+id/glview"  
                android:layout_width="100px"
                android:layout_height="250px"/>
            </LinearLayout>
        </LinearLayout>

        <LinearLayout
        android:layout_marginTop="6dip"
        android:layout_width="fill_parent" 
        android:layout_height="wrap_content" 
        android:layout_weight="1"
        android:orientation="horizontal" >
            <!-- OK/CANCEL BUTTONS -->
        </LinearLayout>
    </LinearLayout>
</ScrollView>
</LinearLayout>

All help much appreciated :)


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


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"


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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜