AI-generated Key Takeaways
-
Adaptive banners use a user-defined width and a Google-optimized height, with height limits ranging from a minimum of 50 density-independent pixels to a maximum of 15% of device height or 90 density-independent pixels, whichever is smaller.
-
For optimal performance, adaptive banners should utilize the full available width while being mindful of safe areas and display cutouts.
-
Creating an anchored adaptive banner involves getting the device's safe width, defining the adaptive ad size, and creating an
AdManagerBannerView
with the specified ad unit ID, size, and position. -
Always test with test ads during development using a provided test ad unit ID or by explicitly configuring your device as a test device.
-
Before implementing adaptive banners, ensure you have followed the instructions in the "Get Started guide" for both the Mobile Ads SDK and banner ads.
Adaptive banners provide a flexible way to display ads, with a user-specified width and a Google-optimized height. The minimum banner height is 50 density-independent pixels, while the maximum is capped at 15% of the device's height or 90 density-independent pixels, whichever is smaller.
These banners perform best when they use the full available width, but you should always consider safe areas and display cutouts that might obstruct visibility when setting the banner's width.
Prerequisites
- Follow the instructions from the Get Started guide.
- Complete the banner Get Started guide.
Always test with test ads
The following sample code contains an ad unit ID which you can use to request test ads. It's been specially configured to return test ads rather than production ads for every request, making it safe to use.
However, after you've registered an app in the Ad Manager web interface and created your own ad unit IDs for use in your app, explicitly configure your device as a test device during development.
/21775744923/example/adaptive-banner
Create an anchored adaptive banner
The following example creates an anchored adaptive banner view positioned to the bottom of the screen:
Replace AD_UNIT_ID with your ad unit ID.
With the anchored adaptive banner view created, you can now load the banner as described in Get Started guide.