我的应用程序底部有一个SMART_BANNER。
以这种方式在Layout XML中声明SMART_BANNER:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/mainLayout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
tools:context=".MainActivity" >
<WebView
android:id="@+id/webview"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<com.google.android.gms.ads.AdView
xmlns:ads="http://schemas.android.com/apk/res-auto"
android:id="@+id/adView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
app:adSize="SMART_BANNER"
app:adUnitId="ca-app-pub-xxxxxxxxx" /> </RelativeLayout>
我的AndroidManifest有这个:
<activity android:name="com.google.android.gms.ads.AdActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize" />
并以这种方式在onCreate中初始化广告:
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.FROYO) {
AdView adView = (AdView)this.findViewById(R.id.adView);
AdRequest adRequest = new AdRequest.Builder()
.addTestDevice(AdRequest.DEVICE_ID_EMULATOR)
.addTestDevice("TEST_DEVICE_ID")
.build();
adView.loadAd(adRequest);
}
当应用以纵向模式启动时,会显示广告;当我将手机置于横向模式时,广告会缩放并且不会填满所有可用空间......即使应用程序以横向模式启动,广告也会显示,但是当我将手机置于纵向模式时,LogCat会显示:
Not enough space to show ad!
为什么呢?我该如何解决这些问题?
抱歉我的英文不好, 提前谢谢!