0

我有以下代码可以在我的游戏顶部显示来自 Admob 的广告。

问题出在这里。我的游戏处于横向模式,但我希望广告以 Potrait 模式出现在顶部。

现状http://postimg.org/image/z4dc271x9/

需要最终输出http://postimg.org/image/83d7afe9h/

我应该在我的代码中更改什么?

 this.mRenderSurfaceView = new RenderSurfaceView(this);

   this.mRenderSurfaceView.setRenderer(this.mEngine,this);
   final android.widget.FrameLayout.LayoutParams surfaceViewLayoutParams = new FrameLayout.LayoutParams(super.createSurfaceViewLayoutParams());

   //Creating the banner view.
   AdView adView = new AdView(this, AdSize.BANNER, "MY_ID_HERE");
   adView.loadAd(new AdRequest());
  final FrameLayout.LayoutParams adViewLayoutParams = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.WRAP_CONTENT, FrameLayout.LayoutParams.WRAP_CONTENT, Gravity.CENTER | Gravity.CENTER_HORIZONTAL);


   final FrameLayout frameLayout = new FrameLayout(this);

   final FrameLayout.LayoutParams frameLayoutLayoutParams = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.FILL_PARENT, FrameLayout.LayoutParams.FILL_PARENT);


   frameLayout.addView(this.mRenderSurfaceView,surfaceViewLayoutParams);
   frameLayout.addView(adView,adViewLayoutParams);

   this.setContentView(frameLayout, frameLayoutLayoutParams);

谢谢!

4

1 回答 1

0

创建 adView 后再添加两行...

//创建横幅视图。

 AdView adView = new AdView(this, AdSize.BANNER, "MY_ID_HERE");
   adView.setRotation(-90.0f);
   adView.setX(-600.0f); // Adjust the value as per your requirement.

然后删除以下行中的“Gravity.CENTER_HORIZONTAL”:

final FrameLayout.LayoutParams adViewLayoutParams = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.WRAP_CONTENT, FrameLayout.LayoutParams.WRAP_CONTENT, Gravity.CENTER | Gravity.CENTER_HORIZONTAL);
于 2014-03-30T08:58:18.823 回答