Reputation: 1617
here is my xml script. i cant seems to figure out how to display admob ads ontop of my videoview. below are my xml codes.
<?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>
Currently it is showing like this
http://img442.imageshack.us/img442/563/img1nve.jpg
But i want it to be like this
http://img854.imageshack.us/img854/1614/img2bv.jpg
Please help . thanks
Upvotes: 1
Views: 1230
Reputation: 8931
Try this version. I took out some unnecessary attributes, aligned the AdMob ad to the top of the screen, and set the video to be below the ad via the android:layout_above
attribute.
<?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>
Upvotes: 1
Reputation: 11
You should add the property android:layout_weight="1" to VideoView tag. See following code:
<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>
I hope this maybe help you.
Upvotes: 1