这是我的 xml 脚本。我似乎无法弄清楚如何在我的视频 View 上显示 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
请帮忙。谢谢
最佳答案
试试这个版本。我去掉了一些不必要的属性,将 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>
关于android - 如何使用 XML 在视频 View 的顶部添加 Admob 广告?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9902602/