我正在使用andengine GLES1 开发(学习构建:))游戏。我覆盖了 setContentView 来放置我的 admob 广告。除了分辨率策略外,一切都很好。我无法按照我想要的方式投放广告。由于我的游戏处于横向模式,因此我希望将广告放置在右侧,并且广告将处于纵向模式。所以我尝试使用相对布局而不是 Frame。这是我的代码
final RelativeLayout relativeLayout = new RelativeLayout(this);
最终 FrameLayout.LayoutParams relativeLayoutLayoutParams = new FrameLayout.LayoutParams(
RelativeLayout.LayoutParams.FILL_PARENT,RelativeLayout.LayoutParams.FILL_PARENT);
this.mRenderSurfaceView = new RenderSurfaceView(this);
mRenderSurfaceView.setRenderer(mEngine);
最终 FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(
FrameLayout.LayoutParams.FILL_PARENT,
FrameLayout.LayoutParams.FILL_PARENT,Gravity.CENTER);
final android.widget.RelativeLayout.LayoutParams surfaceViewLayoutParams = new RelativeLayout.LayoutParams(layoutParams);
surfaceViewLayoutParams.addRule(RelativeLayout.CENTER_IN_PARENT);
relativeLayout.addView(this.mRenderSurfaceView, surfaceViewLayoutParams);
FrameLayout frameLayout = new FrameLayout(this);
adView = new AdView(this, AdSize.BANNER, "a151e9960c73925");
adView.refreshDrawableState();
adView.setVisibility(AdView.VISIBLE);
frameLayout.addView(adView);
相对布局.addView(frameLayout);
this.setContentView(relativeLayout, relativeLayoutLayoutParams);
但它不再显示广告。请帮忙。提前致谢。