注意:我们使用的是版本为4.4的新GooglePlayServices AdMob
当“onCreate”被调用时,我创建内容视图,如下所示:
ContentView = new FrameLayout(this);
FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT);
addContentView(ContentView, params);
当我设置AdView引力时,我会这样做:
FrameLayout.LayoutParams viewParams = new FrameLayout.LayoutParams(320, 50, Gravity.BOTTOM | Gravity.LEFT);
adView.setLayoutParams(viewParams);
任何想法都错了吗?
答案 0 :(得分:3)
设置adview的参数如下:
RelativeLayout.LayoutParams viewParams =
new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT,
RelativeLayout.LayoutParams.WRAP_CONTENT);
viewParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
viewParams.addRule(RelativeLayout.ALIGN_LEFT);
adView.setLayoutParams(viewParams);