简体   繁体   English

Android lib Admob没有足够的空间来显示平板电脑广告

[英]Android lib Admob Not enough space to show ad for tablet

i am building an android lib with AdMob to use on kony platform. 我正在使用AdMob构建一个Android库,以便在kony平台上使用。 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). 该库非常适合Android手机或默认情况下处于纵向模式的平板电脑,但广告不会显示在银河选项卡10.1(默认情况下为横向)中。

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. 看来Admob是在横向模式下获得的尺寸,而不是纵向尺寸。 (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 (要清楚,写这篇文章时,人像是800x1207,风景是1280x800),我不确定问题来自哪里

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. kony平台调用onCreateView来显示广告,我真的不知道这边会发生什么。 This code works fine for any android phone and tablet which are in portrait mode by default. 此代码适用于默认情况下处于纵向模式的任何Android手机和平板电脑。

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. 如果我通过排行榜更改SMART_BANNER,但我也可以在银河10.1上显示广告,但是它不在Kony应用程序的中心,也不如智能横幅广告那么方便。

I don't know android a lot and might have forgot to check something basic. 我不太了解android,并且可能忘记了基本检查。 is there anything i could try to get the correct size before to investigate if it comes from Kony? 在调查它是否来自Kony之前,有什么我可以尝试获得正确尺寸的东西吗?

Thanks 谢谢

Please check your layout for any padding. 请检查您的布局是否有填充。 It just works if you remove any default padding. 如果您删除任何默认填充,它就可以工作。 Cheers! 干杯!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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