views:

369

answers:

1

My ads don't display at all, I think I've followed the documentation correctly but they still won't show. The program is basically a webview and I want the ad to display at the bottom.

Heres my layout file:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
   xmlns:android="http://schemas.android.com/apk/res/android"
   xmlns:myapp="http://schemas.android.com/apk/res/man.utd.headlines"
   android:orientation="vertical"
   android:layout_width="fill_parent"
   android:layout_height="fill_parent">
   <WebView
      android:id="@+id/webview"
      android:layout_width="fill_parent"
      android:layout_height="fill_parent" />
   <com.admob.android.ads.AdView
      android:id="@+id/ad"
      android:layout_width="fill_parent"
      android:layout_height="fill_parent"
      myapp:backgroundColor="#000000"
      myapp:primaryTextColor="#FFFFFF"
      myapp:secondaryTextColor="#CCCCCC" />
</LinearLayout>

Any ideas?

EDIT: this is what I now have but it still doesn't appear to be quite right:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:myapp="http://schemas.android.com/apk/res/man.utd.headlines"
  android:orientation="vertical"
  android:layout_width="fill_parent"
  android:layout_height="fill_parent" >
<com.admob.android.ads.AdView 
    android:id="@+id/ad"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    myapp:backgroundColor="#000000"
    myapp:primaryTextColor="#FFFFFF"
    myapp:secondaryTextColor="#CCCCCC" />
<WebView
    android:id="@+id/webview"
    android:layout_above="@id/ad"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" />
</RelativeLayout>
+1  A: 

Your Problem is that the WebView will take all the space on the screen and there is no space left for the ads.

A LinearLayout will distribute the space on a first come first serve rule. If the first View takes all the space the second view won't get any space..

I would use a RelativeLayout and add the adds first with a layout_alignParentBottom attribute and then add the webview with a layout_above="id for the adds". This will ensure that the adds are always on the bottom of the screen even if the webview wont take all the space at the moment and the webview will always be above the adds.

Janusz
Thanks for that - I seem to be on the right track but I'm still not seeing the ads - would I need to change fill parent? I'm still trying to get my head around Android layouts but thanks for the great help so far.
The Ads should be wrap_content as height and fill_parent as width I assume. The Webview can stay fill_parent. This should lead to a layout where the adds are as big as they need to be and the webview is as big as possible.
Janusz
Hmm it still doesn't appear to be working - just to confirm - does all this look correct? (see update)
Should be ok. Is there a black bar at the bottom of the screen or is the webview taking up all the space?
Janusz
Webview is taking up all of the space. In my admob account i can see that the ads have had a request but they just aren't showing. :(
Heh, got this working. It just didn't like the emu, runs fine on the device :). Thanks for all the help.