Android GLSURFACHEVIEW在滚动视图中,移动但不剪切
我有一个滚动视图,里面有一个线性布局。此线性布局中的一个元素是GLSURFACHEVIEW 这一切都正常工作,当我滚动GLSURFACHEVIEW时,GLSURFACHEVIEW会上下移动,但当GLSURFACHEVIEW到达滚动视图的顶部或底部时,它不会在滚动视图之外继续。此屏幕截图应该更清晰: 不要认为它完全是nessecary,但这是我的layout.xml:Android GLSURFACHEVIEW在滚动视图中,移动但不剪切,android,android-layout,scrollview,clipping,glsurfaceview,Android,Android Layout,Scrollview,Clipping,Glsurfaceview,我有一个滚动视图,里面有一个线性布局。此线性布局中的一个元素是GLSURFACHEVIEW 这一切都正常工作,当我滚动GLSURFACHEVIEW时,GLSURFACHEVIEW会上下移动,但当GLSURFACHEVIEW到达滚动视图的顶部或底部时,它不会在滚动视图之外继续。此屏幕截图应该更清晰: 不要认为它完全是nessecary,但这是我的layout.xml: <?xml version="1.0" encoding="utf-8"?> <LinearLayout xm
<?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>
非常感谢所有帮助:)目前不支持在ScrollView(或Listview等)中托管SurfaceView。这与我们回答的支持无关。问题的原因是
GLSurfaceView
不在视图级别。简言之:对于您的情况,您在第一级有GLSurfaceView
,然后在视图中有holes
的其他视图位于GLSurfaceView
(这由windows管理器处理,并且无论您将GLSurfaceView
放在xml的什么位置,它都将位于第一级,其他视图位于下一级)
因此,您需要的是强制视图更新,这是一个解决办法:您应该在两个框架布局之间放置滚动条,使用GLSurfaceView
或(使用GLSurfaceView
)的RecyclerView)。大概是这样的:
<?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>
----这里应该是glView的线性布局,如果需要,可以使用RecyclerView----
---该框架还要求:---
您可以使用以下行来删除过度滚动:
glView.getHolder().setFormat(PixelFormat.TRANSLUCENT);
glView.setZOrderOnTop(true);
glView.setZOrderMediaOverlay(true);
以及用于删除黑色背景:
linearLayout.setBackgroundColor(context.getResources().getColor(R.color.white));
linearLayout.addView(glView);
同时在清单文件中添加以下行:
android:hardwareAccelerated="true"
关于这个事实有什么变化吗?现在可以使用TextureView来实现所需的效果。TextureView允许您执行SurfaceView所做的操作,但将在滚动视图中工作(并可以设置动画等)。@Romanguy:TextureView与scrollview一起工作,但其他视图与TextureView不兼容。有什么意见吗?嗨,隐形直升机,你找到解决办法了吗?