我正在尝试在游戏场景下添加Admob横幅,但是一些黑色条纹与横幅的一半重叠。 我删除了横幅,看看Admob的问题,但条纹仍然存在。
如何删除它?或者有没有办法在黑条纹上显示横幅?
来源:
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
adView = new AdView(this);
adView.setAdSize(AdSize.BANNER);
adView.setAdUnitId("xxxxxxxxx");
AdRequest adRequest = new AdRequest.Builder().addTestDevice(
AdRequest.DEVICE_ID_EMULATOR).build();
adView.loadAd(adRequest);
adView.setBackgroundColor(Color.BLACK);
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
mGLSurfaceView = new CCGLSurfaceView(this);
background = new LinearLayout(this);
game_layout = new LinearLayout(this);
ad_layout = new LinearLayout(this);
background.setOrientation(LinearLayout.VERTICAL);
ad_layout.setOrientation(LinearLayout.VERTICAL);
game_layout.setOrientation(LinearLayout.VERTICAL);
ad_layout.addView(adView);
game_layout.addView(mGLSurfaceView);
LinearLayout.LayoutParams game_params = new LinearLayout.LayoutParams(
LinearLayout.LayoutParams.MATCH_PARENT,
LinearLayout.LayoutParams.WRAP_CONTENT, 1f);
background.addView(game_layout, game_params);
LinearLayout.LayoutParams ad_params = new LinearLayout.LayoutParams(
LinearLayout.LayoutParams.MATCH_PARENT,
LinearLayout.LayoutParams.WRAP_CONTENT);
background.addView(ad_layout, ad_params);
this.setContentView(background);
}
public void onStart() {
super.onStart();
CCDirector.sharedDirector().attachInView(mGLSurfaceView);
CCDirector.sharedDirector().setDisplayFPS(true);
CCDirector.sharedDirector().setAnimationInterval(1.0f / 60.0f);
CCScene scene = GameStartLayer.scene();
CCDirector.sharedDirector().runWithScene(scene);
}
答案 0 :(得分:0)
我终于找到了横幅被游戏场景夸大的原因。 这个错误实际上是愚蠢的。
必须更新以下方法:
@Override
public void onPause() {
**if (adView != null) adView.pause();**
super.onPause();
CCDirector.sharedDirector().pause();
}
@Override
public void onResume() {
super.onResume();
CCDirector.sharedDirector().resume();
**if (adView != null) adView.resume();**
}