user934820
user934820

Reputation: 1178

Unable to adjust admob ad android

This is my first experience with admob ads and I am unable to adjust ad properly and got an error.

03-18 17:57:58.751: E/Ads(9804): Not enough space to show ad! Wants: <480, 75>, Has: <464, 674>

Any help with layout please. Here is my layout.

<?xml version="1.0" encoding="utf-8"?>
<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
    android:id="@android:id/tabhost"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" >
    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="match_parent"
        android:orientation="vertical"
        android:padding="5dp" >

         <com.google.ads.AdView
            android:id="@+id/adView"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            ads:adSize="BANNER"
            ads:adUnitId="xxxx"
            ads:loadAdOnCreate="true"
            ads:testDevices="TEST_EMULATOR, TEST_DEVICE_ID" />
        <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal" >
            <HorizontalScrollView
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:fillViewport="true"
                android:scrollbars="none" >
                <TabWidget
                    android:id="@android:id/tabs"
                    android:layout_width="235dp"
                    android:layout_height="62dp"
                    android:layout_marginLeft="0dip"
                    android:layout_marginRight="0dip" />
            </HorizontalScrollView>

        </LinearLayout>


        <FrameLayout
            android:id="@android:id/tabcontent"
            android:layout_width="fill_parent"
            android:layout_height="92dp"
            android:layout_weight="0.13"
            android:padding="2dp" >
        </FrameLayout>


    </LinearLayout>

</TabHost>

Upvotes: 0

Views: 77

Answers (1)

Barışcan Kayaoğlu
Barışcan Kayaoğlu

Reputation: 1304

Admob works with specified sizes. BANNER size is declared in the documents. You need to have a valid ad inventory corresponding to your requested ad size.

I struggled a lot with the sizes and came up with a solution, try this

<HorizontalScrollView
        android:layout_width="fill_parent"
        android:layout_height="wrap_content" >

        <com.google.ads.AdView
            android:id="@+id/adView"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            ads:adSize="BANNER"
            ads:adUnitId="xxxx"
            ads:loadAdOnCreate="true"
            ads:testDevices="TEST_EMULATOR, TEST_DEVICE_ID" />
    </HorizontalScrollView>

In my case i had to add a lot more control but this will give you infinite size so that your ad will fit.

Upvotes: 1

Related Questions