Ren*_*K N 7 android andengine andengine-gles-2
我正在开发(学习构建:))与andengine GLES2的游戏.我正在使用Base游戏活动,并且我会覆盖setContent视图以放置我的admob广告.
除了解决方案政策外,每件事情都可以.
比率解析策略是我使用的CAMERA_WIDTH = 800; 和CAMERA_HEIGHT = 480;
问题是,只要覆盖invoiceContentView 场景没有对齐到中心,边距只显示在底部而不是顶部和底部,同样会导致水平对齐时边距将仅显示在右侧,而不是两侧.我怎么能纠正这个.我在下面给出我的代码
@Override
protected void onSetContentView() {
System.out.println("Content setting");
this.mRenderSurfaceView = new RenderSurfaceView(this);
final LayoutParams layoutParams = new LayoutParams(
android.view.ViewGroup.LayoutParams.MATCH_PARENT,
android.view.ViewGroup.LayoutParams.MATCH_PARENT);
layoutParams.gravity = Gravity.LEFT ;
final android.widget.FrameLayout.LayoutParams surfaceViewLayoutParams = new FrameLayout.LayoutParams(
layoutParams);
adView = new AdView(this, AdSize.BANNER, "xxxxxxxxxxxxx");
final FrameLayout.LayoutParams adViewLayoutParams = new FrameLayout.LayoutParams(
FrameLayout.LayoutParams.WRAP_CONTENT,
FrameLayout.LayoutParams.WRAP_CONTENT, Gravity.LEFT
);
final FrameLayout frameLayout = new FrameLayout(this);
final FrameLayout.LayoutParams frameLayoutLayoutParams = new FrameLayout.LayoutParams(
FrameLayout.LayoutParams.FILL_PARENT,
FrameLayout.LayoutParams.FILL_PARENT,Gravity.CENTER);
frameLayout.addView(this.mRenderSurfaceView, surfaceViewLayoutParams);
frameLayout.addView(adView, adViewLayoutParams);
this.setContentView(frameLayout, frameLayoutLayoutParams);
this.mRenderSurfaceView.setRenderer(this.mEngine, this);
}
Run Code Online (Sandbox Code Playgroud)
这里是我得到的图像你可以看到场景下方的白色边缘,如果你选择图像(由于堆栈溢出而没有引起注意也有白色背景)
任何建议都对我很有帮助
我怎么能解决这个Isuue请帮助我
谢谢大家,
固定的:
在与布局进行游戏之后,我能够解决这个问题。
现在,我的表面视图已与中心对齐,并且广告以所需的方式显示。
这是我的代码
@Override
protected void onSetContentView() {
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);
this.mRenderSurfaceView.setRenderer(this.mEngine, this);
final android.widget.RelativeLayout.LayoutParams surfaceViewLayoutParams = new RelativeLayout.LayoutParams(BaseGameActivity.createSurfaceViewLayoutParams());
surfaceViewLayoutParams.addRule(RelativeLayout.CENTER_IN_PARENT);
relativeLayout.addView(this.mRenderSurfaceView, surfaceViewLayoutParams);
FrameLayout frameLayout = new FrameLayout(this);
adView = new AdView(this, AdSize.BANNER, "xxxxxxx");
adView.refreshDrawableState();
frameLayout.addView(adView);
relativeLayout.addView(frameLayout);
this.setContentView(relativeLayout, relativeLayoutLayoutParams);
}
Run Code Online (Sandbox Code Playgroud)