0

私は Java と android の初心者であり、admob 広告を SurfaceView の上に配置する必要がありますが、機能していません。これはレイアウトのコードです:

     <?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
  android:layout_width="fill_parent"
  android:layout_height="fill_parent">

      <com.google.ads.AdView
    android:id="@+id/adView"
    android:layout_height="wrap_content"
    android:layout_width="wrap_content"

    android:layout_alignParentTop="true"
    ads:adSize="BANNER"
    ads:adUnitId="a151e3f18d34b57"
    ads:loadAdOnCreate="true"
    ads:testDevices="TEST_EMULATOR, TEST_DEVICE_ID" />

  <SurfaceView
    android:id="@+id/preview"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
  />


  <ImageView
      android:id="@+id/imageView1"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_centerHorizontal="true"
      android:layout_centerVertical="true"

      android:src="@drawable/gunmask" />


</RelativeLayout>
4

1 に答える 1

2

android:orientation属性と表面の属性をrelativelayoutに配置する必要がありandroid:layout_belowます。

以下は、@id設定した後のビューを配置します。

私は削除しましたandroid:layout_alignParentTop="true"

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
  xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
  android:layout_width="fill_parent"
  android:layout_height="fill_parent"
  android:orientation="vertical">

   <com.google.ads.AdView
    android:id="@+id/adView"
    android:layout_height="wrap_content"
    android:layout_width="wrap_content"
    ads:adSize="BANNER"
    ads:adUnitId="a151e3f18d34b57"
    ads:loadAdOnCreate="true"
    ads:testDevices="TEST_EMULATOR, TEST_DEVICE_ID" />

  <SurfaceView
    android:layout_below="@id/adView"
    android:id="@+id/preview"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"/>


  <ImageView
      android:id="@+id/imageView1"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_centerHorizontal="true"
      android:layout_centerVertical="true"
      android:src="@drawable/gunmask" />
</RelativeLayout>
于 2013-07-16T20:52:52.080 に答える