最近在研究android中的webrtc。
我想单击SurfaceView A 使其全屏,而另一个SurfaceView B 变小,或者单击 B。但我发现很难在运行时更改两个不同 SurfaceView 的 z 顺序。
这是我的布局
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:showIn="@layout/app_bar_main">
<org.webrtc.PercentFrameLayout
android:id="@+id/remote_video_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<org.webrtc.SurfaceViewRenderer
android:id="@+id/remote_video_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</org.webrtc.PercentFrameLayout>
<org.webrtc.PercentFrameLayout
android:id="@+id/local_video_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<org.webrtc.SurfaceViewRenderer
android:id="@+id/local_video_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:keepScreenOn="true" />
</org.webrtc.PercentFrameLayout>
Run Code Online (Sandbox Code Playgroud)
PercentFrameLayout 是 ViewGroup 的子类,用于测量屏幕百分比。
我尝试在运行时使用 setZOrderMediaOverlay 但失败了。我发现SDK说
请注意,必须在将表面视图的包含窗口附加到窗口管理器之前设置此项。
那么这是否意味着我无法在运行时更改SurfaceView z 顺序?或者有什么办法可以破解它吗?
对不起,我的英语不好。
编辑1 SurfaceViewRender和PercentFrameLayout
都来自库,SurfaceViewRender是SurfaceView的子类。
我开发了一个Flutter应用,在“模型”包中定义了服务器模型。
然后,例如在“模型”中声明一个类Example。
型号/示例.dart
class Example {
@override
String toString() {
return 'class example';
}
}
Run Code Online (Sandbox Code Playgroud)
test_a.dart
import 'package:example/model/example.dart'
Example testA() {
return Example()
}
Run Code Online (Sandbox Code Playgroud)
测试飞镖
import 'model/example.dart'
import 'test_a.dart'
test() {
Example example = testA();
if (example is Example) {
print('this class is Example');
} else {
print('$example');
}
}
Run Code Online (Sandbox Code Playgroud)
我会得到输出 class example
如果我在test.dart中从更改import 'model/example.dart'为import 'package:example/model/example.dart',那么我将获得输出this class is Example。
所以我很困惑飞镖的完整路径和相对路径之间的区别。