【问题标题】:Android GLSurfaceView in ScrollView produces black bordersScrollView中的Android GLSurfaceView产生黑色边框
【发布时间】:2015-03-27 09:06:50
【问题描述】:

我有一个 GLSurfaceView,我想把它放在一个 ScrollView 中。我通过在添加到 ScrollView 的 LinearLayout 中添加 FrameLayout 来完成此操作。

一切都很好,除了滚动时 GLSurfaceView 顶部出现黑色边框。当屏幕静止时,一切看起来都很好。任何人都有任何想法。

<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:scrollbars="none"

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="900dp"
            android:orientation="horizontal"
            android:layout_weight="1"
            android:layout_marginStart="10dp"
            android:layout_marginEnd="10dp"
            android:layout_marginTop="35dp"
            android:visibility="visible"
            android:weightSum="1"
            android:overScrollMode="never">

            <FrameLayout
                android:id="@+id/ecg_graph"
                android:layout_width="match_parent"
                android:layout_height="match_parent"/>

【问题讨论】:

标签: android opengl-es scrollview android-framelayout glsurfaceview


【解决方案1】:

一般来说,您不想在屏幕上移动 SurfaceView(或其子类)。请记住,SurfaceView 有两个部分,Surface 和 View。 View 部分——通常只是布局期间使用的一个透明“洞”——由应用程序处理。 Surface部分是由系统合成的一个单独的图形层,其大小和位置由窗口管理器管理。

当你移动一个 SurfaceView 时,View 部分会立即移动,但 Surface 会滞后,因为移动它需要与其他进程通信。您应该会在 View 移动的方向上看到一个黑条,因为您暂时暴露了 Surface 覆盖范围之外的区域。

处理这个问题的首选方法是使用 TextureView,它的行为就像其他视图一样。您需要自己进行 EGL 设置和线程管理,因为 GLSurfaceView 不会为您处理这些。您可以在Grafika 中找到一些示例。

【讨论】:

    猜你喜欢
    • 2013-02-04
    • 2022-01-17
    • 1970-01-01
    • 2014-07-09
    • 2013-01-04
    • 1970-01-01
    • 2010-12-06
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多