Android AdMob未在某些设备上完全显示

Android AdMob未在某些设备上完全显示,android,admob,andengine,ads,2d-games,Android,Admob,Andengine,Ads,2d Games,我最近在谷歌Play上发布了一个应用程序“Meteor Dodge”,该应用程序是在安德林开发的,我在一些设备上显示广告时遇到了问题。看起来广告在开始时只显示了5-10%的高度,但在刷新间隔之后,它看起来很完美。我无法解决此问题,请帮助。这是我的密码: @Override protected void onSetContentView() { // TODO Auto-generated method stub // CREATING the parent FrameLayou

我最近在谷歌Play上发布了一个应用程序“Meteor Dodge”,该应用程序是在安德林开发的,我在一些设备上显示广告时遇到了问题。看起来广告在开始时只显示了5-10%的高度,但在刷新间隔之后,它看起来很完美。我无法解决此问题,请帮助。这是我的密码:

@Override
protected void onSetContentView() {
    // TODO Auto-generated method stub

    // CREATING the parent FrameLayout //
    final FrameLayout frameLayout = new FrameLayout(this);

    // CREATING the layout parameters, fill the screen //
    final FrameLayout.LayoutParams frameLayoutLayoutParams = new FrameLayout.LayoutParams(
            FrameLayout.LayoutParams.MATCH_PARENT,
            FrameLayout.LayoutParams.MATCH_PARENT);


    // CREATING a Smart Banner View //
    this.adView = new AdView(this);
    this.adView.setAdSize(com.google.android.gms.ads.AdSize.BANNER);
    this.adView.setAdUnitId("ca-app-pub-xxxxxxxxxx/xxxxxxxxxx");


    // Doing something I'm not 100% sure on, but guessing by the name //
    adView.refreshDrawableState();
    adView.setVisibility(AdView.VISIBLE);

 // Adview layout //
    final FrameLayout.LayoutParams adViewLayoutParams =
            new FrameLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,
                    FrameLayout.LayoutParams.WRAP_CONTENT,
                                         Gravity.RIGHT|Gravity.TOP); 

    // REQUEST an ad 
    final AdRequest adRequest = new AdRequest.Builder().build();
    adView.loadAd(adRequest); 
    adView.bringToFront();

    // RENDER the add on top of the scene //
    this.mRenderSurfaceView = new RenderSurfaceView(this);
    mRenderSurfaceView.setRenderer(mEngine, this);

    // SURFACE layout ? //
    final android.widget.FrameLayout.LayoutParams surfaceViewLayoutParams =
            new FrameLayout.LayoutParams(super.createSurfaceViewLayoutParams());

    // ADD the surface view and adView to the frame //
    frameLayout.addView(this.mRenderSurfaceView, surfaceViewLayoutParams);
    frameLayout.addView(adView, adViewLayoutParams);

    // SHOW AD //
    this.setContentView(frameLayout, frameLayoutLayoutParams);


}
摆脱(它们不是必需的)

替换

final FrameLayout.LayoutParams adViewLayoutParams =
        new FrameLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,
                FrameLayout.LayoutParams.WRAP_CONTENT,
                                     Gravity.RIGHT|Gravity.TOP); 

最重要的是不要打电话

adView.loadAd(adRequest);

在您将AdView添加到FrameLayout并设置ContentView之前。

我不知道为什么,但这种情况只发生在某些设备上。如果这种情况只发生在某些设备上,则您需要在问题中包含该信息。还要确保你做了一个干净的构建。我正在做一个干净的构建,我确实把它包括在我的问题中。
final FrameLayout.LayoutParams adViewLayoutParams =
        new FrameLayout.LayoutParams(FrameLayout.LayoutParams.WRAP_CONTENT,
                FrameLayout.LayoutParams.WRAP_CONTENT,
                                     Gravity.RIGHT|Gravity.TOP); 
adView.loadAd(adRequest);