Christian Giupponi
Christian Giupponi

Reputation: 7618

Cannot display AdMob banner

I need to put at the bottom of my view the AdMob banner and above it the ScrollView for the content, in tis way the banner shoud always be visibile.

The problemis that my ScrollView fill the whole screen and the logcat sys that I have no space to display the banner.

This is the logcat:

03-14 10:22:56.342    1664-1664/com.elisafedeli.consiglipergenitori.app E/chromium﹕ [ERROR:gl_surface_egl.cc(153)] No suitable EGL configs found.
03-14 10:22:56.352    1664-1664/com.elisafedeli.consiglipergenitori.app E/chromium﹕ [ERROR:gl_surface_egl.cc(620)] GLSurfaceEGL::InitializeOneOff failed.
03-14 10:22:56.352    1664-1664/com.elisafedeli.consiglipergenitori.app E/chromium﹕ [ERROR:gl_surface_egl.cc(153)] No suitable EGL configs found.
03-14 10:22:56.352    1664-1664/com.elisafedeli.consiglipergenitori.app E/chromium﹕ [ERROR:gl_surface_egl.cc(620)] GLSurfaceEGL::InitializeOneOff failed.
03-14 10:22:56.352    1664-1664/com.elisafedeli.consiglipergenitori.app E/chromium﹕ [ERROR:gpu_info_collector.cc(86)] gfx::GLSurface::InitializeOneOff() failed
03-14 10:22:57.282    1664-1695/com.elisafedeli.consiglipergenitori.app E/ActivityThread﹕ Failed to find provider info for com.google.plus.platform
03-14 10:23:08.692    1664-1664/com.elisafedeli.consiglipergenitori.app E/Ads﹕ Not enough space to show ad! Wants: <720, 100>, Has: <720, 0>

This is my Layout:

<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
    android:fillViewport="true"
    android:orientation="vertical">

    <ScrollView
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"

        >

        <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical"
            android:layout_marginLeft="30dp"
            android:layout_marginRight="30dp"
            android:layout_marginBottom="30dp"
            android:fillViewport="true" >

            <!-- Consiglio 1 -->
            <LinearLayout
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:orientation="horizontal"
                android:layout_marginBottom="20dp">

                    <ImageView
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:id="@+id/img1"
                            android:background="@drawable/uno"/>

                        <TextView
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:id="@+id/testoUno"
                            android:text="Consiglio 1"/>

            </LinearLayout>
            <!-- /Consiglio 1 -->

            <!-- Consiglio 2 -->
            <LinearLayout
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:orientation="horizontal"
                android:layout_marginBottom="20dp">

                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:id="@+id/testoDue"
                    android:text="Consiglio 2"/>

                <ImageView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:id="@+id/img2"
                    android:background="@drawable/due"/>

            </LinearLayout>
            <!-- /Consiglio 2 -->

            <!-- Consiglio 3 -->
            <LinearLayout
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:orientation="horizontal"
                android:layout_marginBottom="20dp">

                <ImageView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:id="@+id/img3"
                    android:background="@drawable/tre"/>

                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:id="@+id/testoTre"
                    android:text="Consiglio 3"/>

            </LinearLayout>
            <!-- /Consiglio 3 -->

            <!-- Consiglio 4 -->
            <LinearLayout
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:orientation="horizontal"
                android:layout_marginBottom="20dp">

                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:id="@+id/testoQuattro"
                    android:text="Consiglio 4"/>

                <ImageView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:id="@+id/img4"
                    android:background="@drawable/quattro"/>

            </LinearLayout>
            <!-- /Consiglio 4 -->

            <!-- Consiglio 5 -->
            <LinearLayout
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:orientation="horizontal">

                <ImageView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:id="@+id/img5"
                    android:background="@drawable/cinque"/>

                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:id="@+id/testoCinque"
                    android:text="Consiglio 5"/>

            </LinearLayout>
            <!-- /Consiglio 5 -->

        </LinearLayout>

    </ScrollView>
        <com.google.ads.AdView
            android:id="@+id/adView"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            ads:adUnitId="ca-app-pub-*********/*******"
            ads:adSize="SMART_BANNER"
            ads:loadAdOnCreate="true"
            android:gravity="bottom">

        </com.google.ads.AdView>
</LinearLayout>

I can't understand what I'm missing. Any help is really appriciated!

Upvotes: 0

Views: 240

Answers (2)

nKn
nKn

Reputation: 13761

This happens because your ScrollView's height is defined this way: android:layout_height="wrap_content". So basically, as you have too much things in your layout, it takes all the screen and leaves no space for the AdView.

Probably forcing the height of your AdView to be 100, should show that banner, as right now, as you see, it has no space.

Upvotes: 0

LairdPleng
LairdPleng

Reputation: 974

The clue is here:

03-14 10:23:08.692    1664-1664/com.elisafedeli.consiglipergenitori.app E/Ads﹕ Not enough space to show ad! Wants: <720, 100>, Has: <720, 0>

Set the min-height of the container to 100dp. May as well set the main width, while you're at it.

Upvotes: 1

Related Questions