简体   繁体   中英

Android lib Admob Not enough space to show ad for tablet

i am building an android lib with AdMob to use on kony platform. The lib works great for a android phone or for tablets which are in portrait mode by default, but the Ad doesn't display on the galaxy Tab 10.1 (which is a in landscape by default).

i get this error :

Not enough space to show ad. Needs 1280x90 dp, but only has 800x1207 dp.

it seems that Admob get the size in landscape mode instead of the portrait size. (to be clear, portrait being 800x1207 and landscape 1280x800 when a write about it) and i am not sure where does the issue com from

my application is portrait mode only and i use this code to create my banner :

public View onCreateView(Context context) {

        adView = new PublisherAdView(context);
        adView.setAdUnitId(MY_AD_UNIT_ID);
        adView.setAdSizes(AdSize.SMART_BANNER);

        /*LayoutParams lparams = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
        adView.setLayoutParams(lparams);*/

        PublisherAdRequest.Builder publisherAdRequestBuilder = new PublisherAdRequest.Builder();

        // Optionally populate the ad request builder.
        publisherAdRequestBuilder.addTestDevice("XXXXXXX");
        adView.loadAd(publisherAdRequestBuilder.build());
        return adView;
    }

onCreateView is call by the kony platform to display the Ad and I don't really know what's happen on this side. This code works fine for any android phone and tablet which are in portrait mode by default.

i can also display an Ad on the galaxy 10.1 if I change SMART_BANNER by Leaderboard but it's not centered on the Kony app and not as convenient as the smart banner.

I don't know android a lot and might have forgot to check something basic. is there anything i could try to get the correct size before to investigate if it comes from Kony?

Thanks

Please check your layout for any padding. It just works if you remove any default padding. Cheers!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM