Android - 布局SurfaceView和Image View

Android - Layout SurfaceView and Image View

当我试图将图像视图放在表面视图之上时出现错误。

这是我的XML代码,请在这方面帮助我

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="@android:color/white"
    android:orientation="vertical" >
    <LinearLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#EFE3AF"
    android:orientation="vertical" >
     <FrameLayout 
     android:layout_width="fill_parent"
     android:layout_height="500dp"
     android:layout_weight="1"
            >

      <SurfaceView
         android:id="@+id/surfaceview"
          android:layout_width="fill_parent"
          android:layout_height="wrap_content"
          android:background="@null"
          android:scaleType="fitXY"
          />

  <LinearLayout
      android:layout_width="fill_parent"
      android:layout_height="wrap_content"
      android:layout_gravity="top"
      android:gravity="right"
      android:orientation="vertical"
      android:paddingRight="@dimen/right01"
      android:paddingTop="@dimen/top02" >
      <ImageView
        android:id="@+id/imageView1"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_weight="1" 
        android:src="@drawable/village" />

      </LinearLayout>

        </FrameLayout>
    </LinearLayout>


  </RelativeLayout>

如果我将表面视图向上和图像向下添加,上面的代码工作正常,但我想要其他方式。

是这样的吗?

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@android:color/white"
android:orientation="vertical">

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#EFE3AF"
    android:orientation="vertical">

    <FrameLayout
        android:layout_width="fill_parent"
        android:layout_height="500dp"
        android:layout_weight="1">

        <SurfaceView
            android:id="@+id/surfaceview"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:background="@null"
             />



            <ImageView
                android:layout_gravity="top|right"
                android:id="@+id/imageView1"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:background="#FF0000" />


    </FrameLayout>
</LinearLayout>
</RelativeLayout>