Question

I'm trying to display an Admob ad but this only works in Landscape but not in normal mode.

layout-land/main.xml and layout/main.xml are the same! (well now they are because i deleted everything else to find the bug)

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:myapp="http://schemas.android.com/apk/res/test.testpkg"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="@drawable/background"
    android:padding = "10dip" >

        <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" />

</RelativeLayout>
Was it helpful?

Solution

Remove the padding from your Relative Layout. AdMob doesn't play nice when an ancestor View is padded.

 <RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:myapp="http://schemas.android.com/apk/res/test.testpkg"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="@drawable/background"
    >


 <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"
   />
</RelativeLayout>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top