Is there a way of forcing AdView to take it's initial size immediately upon activity start and stay at that fixed size. As it is now, it changes upon loading of the ads, meaning my renderers onsurfaceChanged function will be called twice upon starting the activity, which causes some initialization to be run twize.
I can work around this, but it would be very very much easier if there was a simple way to assign a fixed size to the banner on inflation. I would prefer not to hardcode dip values for the banner size. My AdView is initialized by the below xml:
<com.google.ads.AdView
android:id="@+id/adView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
ads:adSize="SMART_BANNER"
ads:adUnitId="unit_id"
ads:loadAdOnCreate="true"
ads:testDevices="device_id"
android:visibility="visible" >
</com.google.ads.AdView>
Device/unit ids obviously changed to protect the innocent (me)
Found my own answer after some mucking about. It avoids the hardcoded values and lets me create the AdView purely in xml. Provided below for anyone interested:
I created this subclass of AdView:
}
And changed the xml view to (ids changed again):
Including this in my layout, I now get a fixed size for my AdView, without any code.