2012-03-28 4 views
1

вот мой xml-скрипт. Кажется, я не могу понять, как показывать рекламные объявления на моем видео. ниже приведены мои xml-коды.Как добавить объявления Admob поверх видеоизображения с использованием XML?

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

    <com.google.ads.AdView 
    android:id="@+id/adView" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    ads:adSize="BANNER" 
    ads:adUnitId="myid" 
    android:gravity="top" /> 


    <VideoView android:id="@+id/VideoView" 
      android:layout_width="fill_parent" 
      android:layout_alignParentRight="true" 
      android:layout_alignParentLeft="true" 
      android:layout_alignParentTop="false" 
      android:layout_alignParentBottom="false" 
      android:layout_height="wrap_content"> 
    </VideoView> 
</RelativeLayout> 

В настоящее время он показывает, как этот

http://img442.imageshack.us/img442/563/img1nve.jpg

Но я хочу, чтобы это было как этот

http://img854.imageshack.us/img854/1614/img2bv.jpg

Пожалуйста, помогите. thanks

ответ

1

Попробуйте эту версию. Я извлек некоторые ненужные атрибуты, выровнял объявление AdMob в верхней части экрана и установил, чтобы видео было ниже объявления через атрибут android:layout_above.

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

    <com.google.ads.AdView 
     android:id="@+id/adView" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     ads:adSize="BANNER" 
     ads:adUnitId="myid" 
     android:layout_alignParentTop="true" /> 

    <VideoView android:id="@+id/VideoView" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:layout_above="@id/adView" /> 
</RelativeLayout> 
1

Необходимо добавить собственность android: layout_weight = "1" в тег VideoView. См. Следующий код:

<VideoView android:id="@+id/VideoView" 
      android:layout_width="fill_parent" 
      android:layout_alignParentRight="true" 
      android:layout_alignParentLeft="true" 
      android:layout_alignParentTop="true" 
      android:layout_alignParentBottom="true" 
      android:layout_height="fill_parent" 
      android:layout_weight="1"> 
    </VideoView> 

Я надеюсь, что это может вам помочь.

+0

Thanks NewBi. Но, похоже, он не работает. :) –