Admob ads appear only after first refresh

一个人想着一个人 提交于 2019-11-30 22:58:04

It is hard to say what happens in your case, but I have a suspect that your libgdx screen with the admob banner might show up before the ad finished loading. You can try adding an AdListener that forces the ad-view to draw itself once the ad finished loading. Something like:

    adView.setAdListener(new AdListener() {
        @Override
        public void onAdLoaded() {
            System.out.println("ad banner finished loading!");
            adView.setVisibility(View.GONE);
            adView.setVisibility(View.VISIBLE);
        }        
    });

The code looks a bit odd, but changing visibility should really make sure that your adView gets drawn again ;-)

If you're using a Relative Layout be sure to include the position of the view relative to other layout objects. I was having the same issue until I placed android:layout_below="@+id/adView" on the object directly below my adView object. You could probably just as well place android:layout_above="@+id/someView" on the adView object itself.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!