Smart banner container view will not change

Given the following layout to represent the contents of the main action

<?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:ads="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context=".CordovaApp" tools:ignore="MergeRootFrame" > <LinearLayout android:id="@+id/layout_main" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" android:layout_above="@+id/layout_ad" > </LinearLayout> <RelativeLayout android:id="@+id/layout_ad" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_alignParentBottom="true" android:orientation="vertical" > <com.google.android.gms.ads.AdView android:id="@+id/view_ad" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_centerHorizontal="true" ads:adSize="SMART_BANNER" ads:adUnitId="ca-app-pub-3940256099942544/6300978111" > </com.google.android.gms.ads.AdView> </RelativeLayout> </RelativeLayout> 

I cannot get AdMob smart banners to work when changing orientation.

If I start in landscape mode, I get a smart banner with a height of 32. Changing the portrait orientation does not change the height of the layout_ad , and I get this error

Not enough space to display ads. It requires 480x32 dp, but has only 320x455 dp.

+1
source share
1 answer

AdView needs to be recreated if you use SMART_BANNER and process your own configuration changes. Otherwise, the AdView will not be resized, but the request is still designed to declare the full width in the new orientation, and therefore it is not suitable. Playing AdView in this case may be easier for you in the code than through XML.

+3
source

All Articles