Android 如何在Andengine中使用比率解析策略时更改onSetContentView中的位置

Android 如何在Andengine中使用比率解析策略时更改onSetContentView中的位置,android,admob,andengine,Android,Admob,Andengine,我正在开发(学习构建:)一款使用安德林GLES1的游戏。我覆盖setContentView以放置admob广告。 除处置策略外,所有操作都正常。我不能按我想要的方式放置我的广告。由于我的游戏是在横向模式,我希望广告被放置在右边,广告将在纵向模式。所以我尝试使用相对布局而不是框架。这是我的密码 final RelativeLayout relativeLayout = new RelativeLayout(this); final FrameLayout.LayoutParams

我正在开发(学习构建:)一款使用安德林GLES1的游戏。我覆盖setContentView以放置admob广告。 除处置策略外,所有操作都正常。我不能按我想要的方式放置我的广告。由于我的游戏是在横向模式,我希望广告被放置在右边,广告将在纵向模式。所以我尝试使用相对布局而不是框架。这是我的密码

final RelativeLayout relativeLayout = new RelativeLayout(this); final FrameLayout.LayoutParams relativeLayoutLayoutParams = new FrameLayout.LayoutParams( RelativeLayout.LayoutParams.FILL_PARENT, RelativeLayout.LayoutParams.FILL_PARENT); this.mRenderSurfaceView = new RenderSurfaceView(this); mRenderSurfaceView.setRenderer(mEngine); final 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); relativeLayout.addView(frameLayout); this.setContentView(relativeLayout, relativeLayoutLayoutParams); 最终RelativeLayout RelativeLayout=新的RelativeLayout(本); final FrameLayout.LayoutParams relativeLayoutLayoutParams=新建FrameLayout.LayoutParams( RelativeLayout.LayoutParams.FILL\u父级,RelativeLayout.LayoutParams.FILL\u父级); this.mRenderSurfaceView=新的RenderSurfaceView(this); mRenderSurfaceView.setRenderer(菜单); 最终FrameLayout.LayoutParams LayoutParams=新FrameLayout.LayoutParams( FrameLayout.LayoutParams.FILL\u父级, FrameLayout.LayoutParams.FILL_父对象、重心); 最终的android.widget.RelativeLayout.LayoutParams surfaceViewLayoutParams=新的RelativeLayout.LayoutParams(LayoutParams); SURFACEVEWLAYOUTPARAMS.addRule(父项中的相对位置中心); relativeLayout.addView(this.mRenderSurfaceView、SurfaceView和LayOutParams); FrameLayout FrameLayout=新的FrameLayout(此); adView=新adView(这个,AdSize.BANNER,“a151e9960c73925”); adView.refreshDrawableState(); adView.setVisibility(adView.VISIBLE); frameLayout.addView(adView); relativeLayout.addView(框架布局); this.setContentView(relativeLayout、relativeLayoutLayoutParams);
但它不再播放广告了。请帮忙。提前感谢。

我认为在肖像模式下没有admob横幅。见和。