我將AdMob附加爲BANNER
,但它的平板尺寸很小,所以我將其尺寸更改爲SMART_BANNER
。AdMob SMART_BANNER職位
但橫幅的位置不在底部,但從底部稍高。
,這是我的Android工作室旗幟創建代碼。
mAdView = new AdView(_appActivity);
mAdView.setAdSize(AdSize.SMART_BANNER);
mAdView.setAdUnitId(_appActivity.getResources().getString(R.string.ad_banner));
mAdView.loadAd(adRequest);
/*
LinearLayout linearLayout = new LinearLayout(_appActivity);
LinearLayout.LayoutParams adParams = new LinearLayout.LayoutParams(
LinearLayout.LayoutParams.MATCH_PARENT,
LinearLayout.LayoutParams.WRAP_CONTENT);
adParams.gravity = Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL;
linearLayout.addView(mAdView, adParams);
_appActivity.mFrameLayout.addView(linearLayout);
*/
RelativeLayout relativeLayout = new RelativeLayout(_appActivity);
relativeLayout.setY(0);
_appActivity.mFrameLayout.addView(relativeLayout);
RelativeLayout.LayoutParams adViewParams = new RelativeLayout.LayoutParams(
AdView.LayoutParams.WRAP_CONTENT,
AdView.LayoutParams.WRAP_CONTENT);
// align bottom
adViewParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE);
// align center
adViewParams.addRule(RelativeLayout.CENTER_IN_PARENT, RelativeLayout.TRUE);
relativeLayout.addView(mAdView, adViewParams);
mAdView.setBackgroundColor(Color.BLACK);
mAdView.setBackgroundColor(0);
如何更改代碼?謝謝。