4

I got a realy annoying Problem with adMob and his banner sizes. The smart banner size is a realy good thing, it does almost anything for you, what has to do with sizing ads, but only almost..

In the google docs is a table which sizes the smartbanner supports. There are many sizes supported but not the landscape from a normal android phone.. https://developers.google.com/mobile-ads-sdk/android-legacy/docs/admob/smart-banners

Thats how it looks like now: Portrait - all good

enter image description here

Landscape - dont work

enter image description here

So is there a way to display my ad in landscape at the right way? (this is for the ads:adSize="SMART_BANNER", when i use ads:adSize="BANNER" it display on both but its locked to the size that ads:adSize="BANNER" is giving you, so it look terrible on bigger screens)

XML

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:ads="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingTop="@dimen/activity_vertical_margin"
    android:background="@color/main_bg_color"
    android:id="@+id/rel_bg_home">

<LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical"
        android:weightSum="1"
        android:layout_centerInParent="true"
        >

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Test"
            android:textSize="50sp"
            android:id="@+id/uber"
            android:shadowColor="#000000"
            android:shadowRadius="5"
            android:textStyle="bold"
            android:textColor="@color/text_color"
            android:layout_gravity="center_horizontal"
            android:layout_weight="0.20"
            android:gravity="center|bottom" />

        <LinearLayout
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:orientation="vertical"
            android:layout_gravity="bottom|center_horizontal"
            android:layout_weight="0.30"
            android:gravity="bottom">

            <Button
                android:layout_width="90dp"
                android:layout_height="wrap_content"
                android:text="Play"
                android:id="@+id/play"
                android:textColor="@color/text_color"
                android:layout_marginBottom="20dp" />

            <Button
                android:layout_width="90dp"
                android:layout_height="wrap_content"
                android:text="Help"
                android:id="@+id/help"
                android:textColor="@color/text_color"
                android:layout_below="@+id/play"
                android:layout_marginBottom="20dp" />

            <Button
                android:layout_width="90dp"
                android:layout_height="wrap_content"
                android:text="Score"
                android:textColor="@color/text_color"
                android:id="@+id/score" />
        </LinearLayout>

    </LinearLayout>


    <ImageButton
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:background="@drawable/ic_action_achievement"
        android:layout_alignParentLeft="true"
        android:layout_alignBottom="@+id/toggle"
        android:layout_alignTop="@+id/toggle"
        android:layout_marginLeft="@dimen/activity_horizontal_margin"
        android:id="@+id/highscore"/>

    <ToggleButton
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/toggle"
        android:minHeight="10dp"
        android:minWidth="10dp"
        android:background="@drawable/check"
        android:layout_alignParentRight="true"
        android:focusable="false"
        android:focusableInTouchMode="false"
        android:textOn=""
        android:textOff=""
        android:layout_marginRight="@dimen/activity_horizontal_margin"
        android:layout_above="@+id/adView" />

    <com.google.android.gms.ads.AdView
        android:id="@+id/adView"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerHorizontal="true"
        android:layout_alignParentBottom="true"
        ads:adSize="SMART_BANNER"
        ads:adUnitId="@string/banner_ad_unit_id1">
    </com.google.android.gms.ads.AdView>
</RelativeLayout>
Phil
  • 304
  • 1
  • 5
  • 12
  • 1
    Do you use ads from Admob only or do you have other ads from a mediation setup? – Yoann Hercouet May 07 '16 at 09:27
  • At this point i only testing(use the test ad id from admob), i have no experience with ads and how to monotize, at know i dont understand how the monotize will work, if i had to find a network for ads which display on this banner or if admob automaticly display ads in this banner(in the published version).. – Phil May 07 '16 at 09:31
  • 1
    if you use Admob only for now, SMART_BANNER should be working, I guess it is more related to a problem with your layout. Do you have a specific layout for the landscape mode? You can post your XML anyway. – Yoann Hercouet May 07 '16 at 09:32
  • No i havent a specific layout, but like in docs it says : 533x32, range of sizes from 480x32 to 682x32 Android and Windows Phone 8 devices in Landscape Textads Yes Imageads No – Phil May 07 '16 at 09:38
  • 2
    Try changing `layout_width`, it should be `match_parent`. – Yoann Hercouet May 07 '16 at 09:43
  • Doesn't work, no changes. I got the warning : Ads: Failed to load ad: 3 when i change to landscape, i always read about that. The answer was thats a "Serverside error" but when i use ads:adSize="BANNER" i dont get this warning. – Phil May 07 '16 at 09:50
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/111279/discussion-between-phil-and-yoann-hercouet). – Phil May 07 '16 at 09:52
  • 1
    It's weird, seems to be a problem on their side, but anyway smart banner is not flawless, it is also not compatible with other ad networks such as Facebook than you can use with Mediation. But in your case it should be working since SmartBanner is made for Admob... If there was a problem with the Ad size, the log would explain clearly the width and height required. – Yoann Hercouet May 07 '16 at 09:54

3 Answers3

6

Try to remove any margin or padding attribute from parent view in the xml file.

Hope this help you.

Leenah
  • 850
  • 3
  • 15
  • 36
0

Sometimes smart_banner is not working in landscape mode. So change its size

ads:adSize="BANNER"

Ivan Vovk
  • 929
  • 14
  • 28
-2

Perhaps this open-source solution can help you: https://github.com/ombori/app-banner

either by this:

npm install --save app-banner


var appBanner = require('app-banner');
// - or -
import appBanner from 'app-banner';

appBanner.init({
 apple: 'id1234567890',
 google: 'com.youcompany.yourapp',
 placement: 'bottom-left',
})

or this:

npm install --save app-banner


import AppBanner from 'app-banner/src';

...
<div>
<AppBanner google="com.youcompany.yourapp" apple="id1234567890" 
position="bottom-left" />
</div>
l.ax
  • 24
  • 2