AdMob的广告没有在屏幕的方向正确调整[包括图片] [英] Admob ad not resizing correctly upon screen orientation [Includes Pictures]
问题描述
我使用Admob的在我的应用程序的广告,我遇到了一个问题。每当我打开屏幕为横向模式,广告显示出来,但它是相同的大小,因为它在纵向模式。之后,我加入这个XML声明在我的清单文件,是必要的,以保持应用程序的运作畅顺主要部分我的主要活动这个问题发生:
I am using Admob for ads in my app and I ran into a problem. Whenever I turn the screen to landscape mode, the ad shows up but it's the same size as it was in portrait mode. This problem occured after I added this xml declaration in my manifest to my main activity that was necessary to keep the main parts of the app functioning smoothly:
android:configChanges="orientation|keyboardHidden|screenSize"
我使用智能横幅在我的广告的尺寸:
I am using smart banner in my ad for the size:
ads:adSize="SMART_BANNER"
我重视这个问题的照片:
I have attached pictures of this problem:
我有什么做的就是广告,以在横向模式下适当调整,但不删除
What do I have to do to get the ad to resize properly in landscape mode without deleting
android:configChanges="orientation|keyboardHidden|screenSize"
在清单中我的主要活动?
in the manifest for my main activity?
推荐答案
这是我如何解决它:
@Override
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
orientation_changed = true;
renewAd();
}
private void renewAd() {
AdView ad = (AdView) findViewById(R.id.adView);
LayoutParams lp = (LayoutParams) ad.getLayoutParams();
// change relative layout for your layout which contains the adView
RelativeLayout parent = (RelativeLayout) ad.getParent();
parent.removeView(ad);
AdView newAd = new AdView(this, AdSize.SMART_BANNER, "YOUR ID");
newAd.setId(R.id.adView);
newAd.setLayoutParams(lp);
parent.addView(newAd);
newAd.loadAd(new AdRequest());
}
关于
这篇关于AdMob的广告没有在屏幕的方向正确调整[包括图片]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!