滚动视图内的 glsurfaceview,移动但不剪切
我有一个内部有线性布局的滚动视图。该线性布局中的元素之一是 glsurfaceview。
这一切都工作正常,当我滚动时,glsurfaceview 上下移动,但是当 glsurfaceview 到达滚动视图应被剪切的位置的顶部或底部时,它不会被剪切,并且会在滚动视图之外继续。这个屏幕截图应该更清楚:
不要认为这完全是必要的,但这是我的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>
非常感谢所有帮助:)
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 outside of the scrollview. This screenshot should make it clearer:
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 :)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
当前不支持在 ScrollView(或 Listview 等)内托管 SurfaceView。
Hosting SurfaceViews inside ScrollView (or Listview, etc.) is currently not supported.
您可以使用以下行来删除过度滚动:
以及删除黑色背景:
同时在清单文件中添加以下行:
You may use below lines for removing over scrolling :
And for removing black background :
Also add below line in your manifests file :
这与上面回答的支持无关。问题的原因是
GLSurfaceView
不在视图级别。简而言之:对于您的情况,您在第一级有GLSurfaceView
,然后在GLSurfaceView
上方的视图中具有holes
的其他视图GLSurfaceView
(这处理通过窗口管理器,无论你将GLSurfaceView
放在 xml 上的什么位置,无论如何它都将位于第一级,而其他视图将位于下一级)因此,您需要的是强制视图更新,并且有解决方法:您应该将滚动与
GLSurfaceView
或(带有GLSurfaceViews
的 RecyclerView)放在两个FrameLayouts
之间。像这样的东西: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 haveGLSurfaceView
at the first level, then other views withholes
in views aboweGLSurfaceView
(this handles by windows manager, and it dosent matter where you putGLSurfaceView
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 withGLSurfaceViews
) "between" twoFrameLayouts
. something like this: