私はでゲームを開発しています(構築することを学んでいます:) andengine GLES2
。Baseゲームアクティビティを使用しており、ビューをオーバーライドしsetContent
てAdMob広告を配置しています。
解決ポリシーを除いて、すべて正常に機能します。
比率解決ポリシーは私が一緒に使用しているものですCAMERA_WIDTH = 800; and CAMERA_HEIGHT = 480;
問題は、オーバーライドされるたびに、onsetContentView
シーンが中央に揃えられず、マージンが下部にのみ表示され、上部と下部の両方には表示されないことです。水平方向に配置した場合も同じことが起こります。マージンは右側にのみ表示され、両側には表示されません。どうすればこれを修正できますか?私は以下に私のコードを与えています:
@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);
}
これが私が得た画像です。画像を選択すると、シーンの下の白い余白が見えます(スタックオーバーフローのために注目されませんが、背景も白いです)
どんな提案も私に完全に役立つでしょう
どうすればこの問題を解決できますか助けてください
ありがとうございます、