2

I am trying to add ads to my layout on top of it.

<?xml version="1.0" encoding="utf-8"?>



<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/bg" >

<LinearLayout
    android:id="@+id/ll"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    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="xxxxxxxxxxxxxxxxxxxxx"
        ads:loadAdOnCreate="true" />

    <TextView
        android:id="@+id/feststatic"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:padding="3dp"
        android:text="@string/festname"
        android:textColor="@color/white"
        android:textSize="22dp" />

    <TextView
        android:id="@+id/festival"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:padding="3dp"
        android:text=""
        android:textColor="#C2DFFF"
        android:textSize="18dp" />

    <TextView
        android:id="@+id/daystatic"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:padding="3dp"
        android:text="@string/weekday"
        android:textColor="@color/white"
        android:textSize="22dp" />

    <TextView
        android:id="@+id/day"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:padding="3dp"
        android:text=""
        android:textColor="#C2DFFF"
        android:textSize="18dp" />

    <TextView
        android:id="@+id/monthstatic"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:padding="3dp"
        android:text="@string/month"
        android:textColor="@color/white"
        android:textSize="22dp" />

    <TextView
        android:id="@+id/month"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:padding="3dp"
        android:text=""
        android:textColor="#C2DFFF"
        android:textSize="18dp" />

    <TextView
        android:id="@+id/fulldatestatic"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:padding="3dp"
        android:text="@string/date"
        android:textColor="@color/white"
        android:textSize="22dp" />

    <TextView
        android:id="@+id/fulldate"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:padding="3dp"
        android:text=""
        android:textColor="#C2DFFF"
        android:textSize="18dp" />

    <TextView
        android:id="@+id/descstatic"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:padding="3dp"
        android:text="@string/desc"
        android:textColor="@color/white"
        android:textSize="22dp" />

    <TextView
        android:id="@+id/desc"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:padding="3dp"
        android:text=""
        android:textColor="#C2DFFF"
        android:textSize="18dp"
        android:typeface="serif" />
</LinearLayout>



 </ScrollView>

The above is my Xml layout file but when i run it i get this error "Not enough space to show ad! Wants: <320, 50>, Has: <310, 1073741823>" I didn't give any padding to the scrollview.

Any help would be appreciated.Thanks in advance.

4 Answers 4

2

My bad..I gave padding to linear layout...I removed it and it worked like charm.

0

End the file with </ScrollView>, just below </LinearLayout

5
  • Thanks.I have the scrollview end statement. Jan 7, 2012 at 14:07
  • Try removing all the text views first. if problem still persist, it might be the ad.
    – Hend
    Jan 7, 2012 at 14:11
  • 1
    can i fix the ad at the bottom of the screen? Jan 7, 2012 at 14:29
  • 1
    Yes. Create a RelativeLayout as parent of scrollview. then put the admob child of the layout instead of scrollview and set layout to bottom.
    – Hend
    Jan 7, 2012 at 14:39
  • @Hend: thank you..it works..to fix it i use your idea..I also use android:layout_alignParentBottom="true" android:layout_centerHorizontal="true" in ads Activity. Aug 28, 2013 at 21:17
0

Why not use a relativeLayout instead? Also consider reading this:

http://googleadsdeveloper.blogspot.com/2011/12/incorporating-android-admob-ads-into.html

0

From: @Hend Create a RelativeLayout as parent of scrollview. Then put the admob view as a child of the RelativeLayout instead of scrollview and use android:layout_alignParentBottom="true" android:layout_centerHorizontal="true" in it(admov view).

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
android:layout_width="match_parent"
android:layout_height="match_parent" >

<ScrollView
    android:layout_width="match_parent"
    android:layout_height="match_parent" >

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent" >

        <TextView
            android:id="@+id/textViewGeneralHeader"
            style="@style/heading_text"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentLeft="true"
            android:layout_alignParentTop="true"
            android:layout_marginLeft="10dp"
            android:layout_marginTop="5dp"
            android:text="General Info" />

        <ImageView
            android:id="@+id/imageViewLine1"
            android:layout_width="fill_parent"
            android:layout_height="1dp"
            android:layout_below="@+id/textViewGeneralHeader"
            android:layout_marginTop="5dp"
            android:background="@drawable/line" />

        <TextView
            android:id="@+id/textViewGenealDescription"
            style="@style/description"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignLeft="@+id/textViewGeneralHeader"
            android:layout_below="@+id/imageViewLine1"
            android:layout_marginTop="10dp"
            android:text="Description" />

        <ImageView
            android:id="@+id/imageViewLine2"
            android:layout_width="fill_parent"
            android:layout_height="1dp"
            android:layout_below="@+id/textViewGenealDescription"
            android:layout_marginTop="5dp"
            android:background="@drawable/line" />

        <TextView
            android:id="@+id/textViewDisplayHeader"
            style="@style/heading_text"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignLeft="@+id/textViewGeneralHeader"
            android:layout_below="@+id/imageViewLine2"
            android:layout_marginTop="5dp"
            android:text="Display Info" />

        <ImageView
            android:id="@+id/imageViewLine3"
            android:layout_width="fill_parent"
            android:layout_height="1dp"
            android:layout_below="@+id/textViewDisplayHeader"
            android:layout_marginTop="5dp"
            android:background="@drawable/line" />

        <TextView
            android:id="@+id/textViewDisplayDescription"
            style="@style/description"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignLeft="@+id/textViewGeneralHeader"
            android:layout_below="@+id/imageViewLine3"
            android:layout_marginTop="10dp"
            android:text="Description" />

        <ImageView
            android:id="@+id/imageViewLine4"
            android:layout_width="fill_parent"
            android:layout_height="1dp"
            android:layout_below="@+id/textViewDisplayDescription"
            android:layout_marginTop="5dp"
            android:background="@drawable/line" />
    </RelativeLayout>
</ScrollView>

<com.google.ads.AdView
    android:id="@+id/adView"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    android:layout_centerHorizontal="true"
    ads:adSize="BANNER"
    ads:adUnitId="a14e2f8fe3af5a6"
    ads:loadAdOnCreate="true" >
</com.google.ads.AdView></RelativeLayout>

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.