显示增加了在游戏中的AndEngine Android的 [英] Showing adds in gameplay in AndEngine Android
本文介绍了显示增加了在游戏中的AndEngine Android的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
您好我想显示在游戏中AndEngine顶部增加。 任何一个可以帮我这个?
Hi I want to show adds at the top of the game in AndEngine. Can any one help me with this??
推荐答案
哎呀我得到了答案,所以发布。
Oops I got the answer so posting.
@Override
protected void onSetContentView() {
final FrameLayout frameLayout = new FrameLayout(this);
final FrameLayout.LayoutParams frameLayoutLayoutParams =
new FrameLayout.LayoutParams(FrameLayout.LayoutParams.FILL_PARENT,
FrameLayout.LayoutParams.FILL_PARENT);
final AdView adView = new AdView(this, AdSize.BANNER, "XXXXXXXXXXXXXXXXX");
adView.refreshDrawableState();
adView.setVisibility(AdView.VISIBLE);
final FrameLayout.LayoutParams adViewLayoutParams =
new FrameLayout.LayoutParams(FrameLayout.LayoutParams.WRAP_CONTENT,
FrameLayout.LayoutParams.WRAP_CONTENT,
Gravity.CENTER_HORIZONTAL);
/*
int height = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 50,
getResources ().getDisplayMetrics ());*/
// top of AD is at middle of the screen
adViewLayoutParams.topMargin = 0;
AdRequest adRequest = new AdRequest();
adRequest.addTestDevice( AdRequest.TEST_EMULATOR);
adView.loadAd(adRequest);
this.mRenderSurfaceView = new RenderSurfaceView(this);
mRenderSurfaceView.setRenderer(mEngine);
final android.widget.FrameLayout.LayoutParams surfaceViewLayoutParams =
new FrameLayout.LayoutParams(super.createSurfaceViewLayoutParams());
frameLayout.addView(this.mRenderSurfaceView, surfaceViewLayoutParams);
frameLayout.addView(adView, adViewLayoutParams);
this.setContentView(frameLayout, frameLayoutLayoutParams);
}
这篇关于显示增加了在游戏中的AndEngine Android的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文