我遇到了同样的问题,但是找到了解决方法。
我的AdView位于页面底部的相对布局中。加载时看起来正确,所以我认为
LayoutParams是正确的。要解决此问题,我必须从中删除所有内容
RelativeLayout,创建一个新的AdView,然后以正确的顺序将其全部添加回原来的
LayoutParams。
就像是:
@Overridepublic void onConfigurationChanged(Configuration newConfig) { super.onConfigurationChanged(newConfig); AdView adView = (AdView)findViewById(R.id.adView); View contentframe = findViewById(R.id.contentframeLayout); RelativeLayout parent = (RelativeLayout) adView.getParent(); LayoutParams mapframeParams = contentframe.getLayoutParams(); LayoutParams adViewParams = adView.getLayoutParams(); parent.removeView(adView); parent.removeView(contentframe); AdView newAdView = new AdView(this, AdSize.SMART_BANNER, getString(R.string.admob_pubId)); newAdView.setId(R.id.adView); parent.addView(newAdView, adViewParams); parent.addView(contentframe,mapframeParams); newAdView.loadAd(new AdRequest());}这对我有效,但仍然感觉像是黑客。



