2

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>
6
  • What is the problem? An exception, unexpected behaviour, problems with the layout...
    – Impression
    Commented Nov 25, 2010 at 22:54
  • no exception, just the admob ap isnt displayed in portrait orientation.. only in landscape I can see it
    – martinyyyy
    Commented Nov 25, 2010 at 22:58
  • Please try to set android:background="#ff0000" at your AdView to be sure, that the AdView itself gets shown or not. If you you see a red area, the code of the AdView may have problems with the positioning of its content in the portrait aspect view.
    – Impression
    Commented Nov 25, 2010 at 23:05
  • Ok the AdView gets displayed in both directions. The layout description seems to be right. I think, there must be something wrong with the code of the view. How do you calculate the positioning of the content of the AdView? Maybe you should debug your draw method. Maybe you have the wrong bounds and therefore the wrong midpoint and places the banner outside ...
    – Impression
    Commented Nov 25, 2010 at 23:20

1 Answer 1

3

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>
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.