in Manifest:
<activity
android:theme="@style/MyThemeDetails"
android:name="Activity"
android:configChanges="keyboardHidden|orientation|screenSize"
android:label="@string/app_name" >
</activity>
所以当我旋转设备onCreate不会再次调用时,这就是为什么adView不会使用AdSize.SMART_BANNER
重新加载,并且横向模式下的尺寸仍为320x50
但我需要横向模式大小(full_wigthx32)(下面的屏幕)
我需要在onConfigurationChanged中添加什么来重新加载adView的大小?
private void addBaner() {
adView = new AdView(this);
adView.setAdUnitId(getString(R.string.ads_id));
adView.setAdSize(AdSize.SMART_BANNER);
adLayout = (LinearLayout) findViewById(R.id.l_edds);
adLayout.addView(adView);
AdRequest adRequest = new AdRequest.Builder().build();
adView.loadAd(adRequest);
}
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
}
答案 0 :(得分:0)
这不会起作用吗?
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
addBanner();
}
答案 1 :(得分:0)
您是否在清单中正确包含了AdActivity?
<!--Include the AdActivity configChanges and theme. -->
<activity android:name="com.google.android.gms.ads.AdActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"
android:theme="@android:style/Theme.Translucent" />