我正在尝试创建一个游戏。我使用 Surfaceview 进行绘图,现在我希望在屏幕底部显示一个 admob 视图。我试图以编程方式创建一个 RelativeLayout ,但目前唯一要显示的视图是 surfaceview ,没有显示 admob 视图!
这是代码:
RelativeLayout layout = new RelativeLayout(this);
AdView admobView = new AdView(this, AdSize.BANNER, "MY_ADMOB_ID");
RelativeLayout.LayoutParams admobParams = new RelativeLayout.LayoutParams(
RelativeLayout.LayoutParams.WRAP_CONTENT,
RelativeLayout.LayoutParams.WRAP_CONTENT);
admobParams.addRule(RelativeLayout.ALIGN_BOTTOM);
admobView.setLayoutParams(admobParams);
layout.addView(admobView);
RelativeLayout.LayoutParams threadParams = new RelativeLayout.LayoutParams(
RelativeLayout.LayoutParams.WRAP_CONTENT,
RelativeLayout.LayoutParams.WRAP_CONTENT);
threadParams.addRule(RelativeLayout.ALIGN_PARENT_TOP);
admobView.loadAd(new AdRequest());
TimermodeThread timerThread = new TimermodeThread(getApplicationContext());
timerThread.setLayoutParams(threadParams);
layout.addView(timerThread);
setContentView(layout);
有没有人可以帮助我?
谢谢!
编辑
我可以在日志中看到我收到了广告。所以,我猜surfaceview占用了所有空间!