AI-generated Key Takeaways
-
Adaptive banners optimize ad size for each device, maximizing performance by using fixed aspect ratios instead of fixed heights.
-
They are drop-in replacements for standard 320x50 banners and smart banners, offering better screen space utilization and accounting for safe areas and cutouts.
-
Adaptive banners dynamically adjust height to the device, providing a more consistent ad experience while requiring developers to accommodate height variances in their layout.
-
Implementation involves getting the device width, using the appropriate AdSize method for orientation, and creating a BannerView with the adaptive size and ad unit ID.
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 AdMob web interface and created your own ad unit IDs for use in your app, explicitly configure your device as a test device during development.
Android
ca-app-pub-3940256099942544/9214589741
iOS
ca-app-pub-3940256099942544/2435281174
Create an anchored adaptive banner
The following example creates an anchored adaptive banner view positioned to the bottom of the screen:
Replace ANCHORED_ADAPTIVE_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.