2014-10-02 59 views
-1

我在一个FrameLayout中创建两个表面。 我的问题是,每个表面单独工作,但是当我想在同一时间运行它们时,屏幕是黑色的。Android活动上的两个表面

我想把每个表面放在屏幕的一半。

回答

1

将FrameLayout更改为LinearLayout。为每一个设置一个权重,他们将填充屏幕的一半。

<?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>