我有以下代码可以在我的游戏中显示来自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);
谢谢!
答案 0 :(得分: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);