0

I have problem with displaying AdMob banners on small screens(In landscape mode is working). Tested on Galaxy S4, ads are shown, but on small screens only in landscape mode. I have tried changing xml layout parameters(width and height) to match_parent,wrap_content and fill_parent, but still same thing.

Error stack trace: 02-24 16:30:36.327: W/Ads(396): Not enough space to show ad. Needs 320x50 pixels, but only has 208x239 pixels.

My xml is:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@raw/backgroundc"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context=".MainActivity" >

    <Button
        android:id="@+id/buttonGetLuck"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerHorizontal="true"
        android:layout_centerVertical="true"
        android:background="@layout/get_luck_custom_button"
        android:onClick="buttonGetLuck"
        android:text="Get Lucky"
        android:textStyle="italic"
        android:typeface="sans" />

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="16dp"
        android:text="See your luck for today."
        android:textColor="#7CFC00"
        android:textSize="18sp"
        android:textStyle="italic"
        android:typeface="serif" />

    <LinearLayout
        android:id="@+id/bannerLayuout"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:orientation="horizontal"
        android:layout_centerHorizontal="true"/>

</RelativeLayout>

My code is:

 // Create the adView.
    adView = new AdView(this);
    adView.setAdUnitId("*******");
    adView.setAdSize(AdSize.BANNER);

    // AdMob banner layout
    LinearLayout layout = (LinearLayout)findViewById(R.id.bannerLayuout);

    // Add the adView to it.
    layout.addView(adView);

    // Initiate a generic request.
    AdRequest adRequest = new AdRequest.Builder().build();

    // Load the adView with the ad request.
    adView.loadAd(adRequest);
Kostadin Georgiev
  • 866
  • 1
  • 9
  • 23
  • I have also testet with AdSize.SMART_BANNER but still doesn't work... – Kostadin Georgiev Feb 24 '14 at 14:30
  • If you can't see a View and you're sure it should be there. Try adding a ScrollView to the parent View. This will allow you to see if the child View is being pushed off the screen. I think that's what your layout's problem is right now – Aftab Safdar Feb 24 '14 at 14:34
  • ScrollView doesn't help. The banner have a static size 320x50 and if the device doesn't have this resolution how to dynamically change it to the device's supported resolution. – Kostadin Georgiev Feb 25 '14 at 08:39

1 Answers1

1

I think that the problem could be "padding" on parent view.

try to remove these lines:

android:paddingLeft="@dimen/activity_horizontal_margin" android:paddingRight="@dimen/activity_horizontal_margin"

Tony
  • 11
  • 1