user2909337
user2909337

Reputation: 25

Not Enough Space To Show Ad

Here is my XML layout code which gives the error of not enough space. Seems like the width is not big enough which I find extremely strange. Not Enough Space To Show Add! Want <480, 85> Has <432, 676> This is the error im gettin in the logcat.

<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:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:background="@drawable/backgr2"
tools:context=".MainActivity" >



    <TextView
        android:id="@+id/textView5"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true"
        android:layout_alignParentLeft="true"
        android:textColor="#fff"
        android:text="Some Text" />

    Maybe this gridview takes too much of the screen?
    <GridView
        android:id="@+id/gridView1"
        android:layout_below="@+id/textView5"
        android:layout_width="match_parent"
        android:layout_height="131dp"
        android:background="@drawable/bakgr"
        android:gravity="center"
        android:horizontalSpacing="0dp"
        android:numColumns="3"
        android:verticalSpacing="5dp" >
    </GridView>

    <TextView
        android:id="@+id/textView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@+id/gridView1"
        android:textSize="20sp"
        android:textStyle="italic"
        android:text="Some Text" />

    <TextView
        android:id="@+id/textView2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@+id/textView1"
        android:textSize="20sp"
        android:textStyle="bold" />

    <TextView
        android:id="@+id/textView3"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@+id/textView2"
         />

    <Button
        android:id="@+id/button1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_alignRight="@+id/gridView1"
        android:layout_marginBottom="40dp"
        android:background="@drawable/button_state"
         />

    This is the adview which cannot be displayed for I dont know what reason!
    <com.google.ads.AdView android:id="@+id/adView"
                     android:layout_width="match_parent"
                     android:layout_height="wrap_content"
                     android:layout_alignParentBottom="true"
                     ads:adUnitId="XXXX"
                     ads:testDevice="TEST_EMULATOR"
                     ads:adSize="BANNER"
                     ads:loadAdOnCreate="true"/>

</RelativeLayout>

Yeah.. Please Help

Upvotes: 1

Views: 577

Answers (3)

Ravi
Ravi

Reputation: 35539

just remove

       android:paddingBottom="@dimen/activity_vertical_margin"
       android:paddingLeft="@dimen/activity_horizontal_margin"
       android:paddingRight="@dimen/activity_horizontal_margin"
       android:paddingTop="@dimen/activity_vertical_margin"

from relative layout and your problem is solved

Upvotes: 1

William
William

Reputation: 20196

It is the left and right padding of the RelativeLayout. Remove that and it will work.

Upvotes: 0

Elad Nava
Elad Nava

Reputation: 7906

The problem is the RelativeLayout padding specified in the root element. It affects the AdView as well, and this is the reason you are getting this error.

Move the padding specifically to the elements that need it, or wrap those elements in an additional LinearLayout and give it the padding it needs.

Upvotes: 3

Related Questions