gpt4 book ai didi

Android GLSurfaceView在ScrollView中产生黑边

转载 作者:太空狗 更新时间:2023-10-29 16:15:29 26 4
gpt4 key购买 nike

我有一个 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"/>

enter image description here

最佳答案

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

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

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

关于Android GLSurfaceView在ScrollView中产生黑边,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29296853/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com