我将 AdMob 附加为BANNER
,但它在平板电脑中太小了,所以我将它的大小更改为SMART_BANNER
.
但是横幅的位置不在底部,而是从底部稍微高一点。
这是我的 android-studio 横幅创建代码。
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);
我如何更改代码?谢谢。