我在一个FrameLayout中创建了两个表面。 我的问题是每个表面都是单独工作的,但是当我想同时运行它们时,屏幕是黑色的。
我想将每个表面都放在屏幕的一半。
答案 0 :(得分:1)
将FrameLayout更改为LinearLayout。为每个重量设置为1,它们将填满屏幕的一半。
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:orientation="vertical"
android:layout_height="match_parent">
<SurfaceView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/surfaceView1"
android:layout_weight="1"/>
<SurfaceView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/surfaceView2"
android:layout_weight="1"/>
</LinearLayout>