Inline adaptive banner ads
Stay organized with collections
Save and categorize content based on your preferences.
Adaptive banners let you specify the width of an ad to determine the optimal
ad size. Adaptive banners also maximize performance by optimizing the ad size
for each device. This approach results in opportunities for
improved performance.
Compared to anchored adaptive banners, inline adaptive banners are larger,
taller, and use variable instead of fixed heights. Inline adaptive banners are
of variable height, and might encompass the entire screen or a maximum height
that you specify.
You place inline adaptive banners in scrolling content, for example:

Before you begin
Before continuing, make sure you have completed the getting started guide,
Banner ads.
Implement adaptive banners
Unlike anchored adaptive banners, inline adapter banners load using an inline
adaptive banner size. To create an inline adaptive ad size, complete the
following:
Get the width of the device in use, or set your own width if you don't want
to use the full width of the screen.
Use the appropriate static methods on the ad size class, such as
AdSize.getCurrentOrientationInlineAdaptiveBannerAdSize(Context context, int width)
to get an inline adaptive ad size object for the chosen orientation.
The following example demonstrates these steps:
Kotlin
private fun loadAd() {
// Create an inline adaptive ad size. 320 is a placeholder value.
// Replace 320 with your banner container width.
val adSize = AdSize.getCurrentOrientationInlineAdaptiveBannerAdSize(this, 320)
// Step 1 - Create a BannerAdRequest object with ad unit ID and size.
val adRequest = BannerAdRequest.Builder("AD_UNIT_ID", adSize).build()
// Step 2 - Load the ad.
BannerAd.load(
adRequest,
object : AdLoadCallback<BannerAd> {
override fun onAdLoaded(ad: BannerAd) {
// Assign the loaded ad to the BannerAd object.
bannerAd = ad
// Step 3 - Call BannerAd.getView() to get the View and add it
// to view hierarchy on the UI thread.
activity?.runOnUiThread {
binding.bannerViewContainer.addView(ad.getView(requireActivity()))
}
}
override fun onAdFailedToLoad(loadAdError: LoadAdError) {
bannerAd = null
}
}
)
}
Java
private void loadAd() {
// Create an inline adaptive ad size. 320 is a placeholder value.
// Replace 320 with your banner container width.
AdSize adSize = AdSize.getCurrentOrientationInlineAdaptiveBannerAdSize(this, 320);
// Step 1 - Create a BannerAdRequest object with ad unit ID and size.
BannerAdRequest adRequest = new BannerAdRequest.Builder("AD_UNIT_ID",
adSize).build();
// Step 2 - Load the ad.
BannerAd.load(
adRequest,
new AdLoadCallback<BannerAd>() {
@Override
public void onAdLoaded(@NonNull BannerAd ad) {
// Assign the loaded ad to the BannerAd object.
bannerAd = ad;
// Step 3 - Call BannerAd.getView() to get the View and add it
// to view hierarchy on the UI thread.
if (getActivity() != null) {
getActivity()
.runOnUiThread(() ->
binding.bannerViewContainer.addView(ad.getView(getActivity())));
}
}
@Override
public void onAdFailedToLoad(@NonNull LoadAdError adError) {
bannerAd = null;
}
});
}
When implementing adaptive banners in your app, note these points:
- The inline adaptive banner sizes work best when using the full available
width. In most cases, this size is the full width of the device screen in
use, or the full width of the banner's parent content. You must know the width
of the view to place in the ad, the device width, the parent content width,
and applicable safe areas.
- You may need to update or create new line items to work with adaptive
sizes. Learn more.
Orient inline adaptive banner size
To preload an inline adaptive banner ad for a specific orientation, use the
following methods:
If your app supports both portrait and landscape views, and you want to preload
an adaptive banner ad in the current orientation, use
AdSize.getCurrentOrientationInlineAdaptiveBannerAdSize(Context context, int width)
This method loads an ad in the current orientation.
Limit inline adaptive banner height
By default, inline adaptive banners instantiated without a maxHeight
value
have a maxHeight
equal to the device height. To limit the inline adaptive
banner height, use the
AdSize.getInlineAdaptiveBannerAdSize(int width, int maxHeight)
method.
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-08-22 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-22 UTC."],[[["\u003cp\u003eAdaptive banners optimize ad size for each device to maximize performance.\u003c/p\u003e\n"],["\u003cp\u003eInline adaptive banners, placed within scrolling content, are larger and use variable heights compared to anchored adaptive banners.\u003c/p\u003e\n"],["\u003cp\u003eImplement inline adaptive banners by getting the device width, creating an inline adaptive ad size, and loading the ad using \u003ccode\u003eBannerAd.load()\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eEnsure your line items support adaptive sizes and consider the full available width for optimal performance with inline adaptive banners.\u003c/p\u003e\n"]]],[],null,["Adaptive banners let you specify the width of an ad to determine the optimal\nad size. Adaptive banners also maximize performance by optimizing the ad size\nfor each device. This approach results in opportunities for\nimproved performance.\n\nCompared to anchored adaptive banners, inline adaptive banners are larger,\ntaller, and use variable instead of fixed heights. Inline adaptive banners are\nof variable height, and might encompass the entire screen or a maximum height\nthat you specify.\n\nYou place inline adaptive banners in scrolling content, for example:\n\nBefore you begin\n\nBefore continuing, ensure you have completed the getting started guide,\n[Banner ads](/ad-manager/mobile-ads-sdk/android/early-access/nextgen/banner).\n\nImplement adaptive banners\n\nUnlike anchored adaptive banners, inline adapter banners load using an inline\nadaptive banner size. To create an inline adaptive ad size, complete the\nfollowing:\n\n1. Get the width of the device in use, or set your own width if you don't want to use the full width of the screen.\n2. Use the appropriate static methods on the ad size class, such as `AdSize.getCurrentOrientationInlineAdaptiveBannerAdSize(Context context, int width)` to get an inline adaptive ad size object for the chosen orientation.\n3. If you want to limit the height of the banner, use the static method `AdSize.getInlineAdaptiveBannerAdSize(int width, int maxHeight)` .\n\nThe following example demonstrates these steps: \n\nKotlin \n\n private fun loadAd() {\n // Create an inline adaptive ad size. 320 is a placeholder value.\n // Replace 320 with your banner container width.\n val adSize = AdSize.getCurrentOrientationInlineAdaptiveBannerAdSize(this, 320)\n\n // Step 1 - Create a BannerAdRequest object with ad unit ID and size.\n val adRequest = BannerAdRequest.Builder(&\u003cvar scope=\"AD_UNIT_ID\" translate=\"no\"\u003equot;AD_UN\u003c/var\u003eIT_ID\", adSize).build()\n\n // Step 2 - Load the ad.\n BannerAd.load(\n adRequest,\n object : AdLo\u003cadCallba\u003eckBannerAd {\n override fun onAdLoaded(ad: BannerAd) {\n // Assign the loaded ad to the BannerAd object.\n bannerAd = ad\n // Step 3 - Call BannerAd.getView() to get the View and add it\n // to view hierarchy on the UI thread.\n activity?.runOnUiThread {\n binding.bannerViewContainer.addView(ad.getView(requireActivity()))\n }\n }\n\n override fun onAdFailedToLoad(loadAdError: LoadAdError) {\n bannerAd = null\n }\n }\n )\n }\n\nJava \n\n private void loadAd() {\n // Create an inline adaptive ad size. 320 is a placeholder value.\n // Replace 320 with your banner container width.\n AdSize adSize = AdSize.getCurrentOrientationInlineAdaptiveBannerAdSize(this, 320);\n\n // Step 1 - Create a BannerAdRequest object with ad unit ID and size.\n BannerAdRequest adRequest = new BannerAdRequest.Builder(&\u003cvar scope=\"AD_UNIT_ID\" translate=\"no\"\u003equot;AD_UN\u003c/var\u003eIT_ID\",\n adSize).build();\n\n // Step 2 - Load the ad.\n BannerAd.load(\n adRequest,\n new AdLo\u003cadCallba\u003eckBannerAd() {\n @Override\n public void onAdLoaded(@NonNull BannerAd ad) {\n // Assign the loaded ad to the BannerAd object.\n bannerAd = ad;\n // Step 3 - Call BannerAd.getView() to get the View and add it\n // to view hierarchy on the UI thread.\n if (getActivity() != null) {\n getActivity()\n .runOnUiT\u003ehread(() -\n binding.bannerViewContainer.addView(ad.getView(getActivity())));\n }\n }\n\n @Override\n public void onAdFailedToLoad(@NonNull LoadAdError adError) {\n bannerAd = null;\n }\n });\n }\n\nWhen implementing adaptive banners in your app, note these points:\n\n- The inline adaptive banner sizes work best when using the full available width. In most cases, this size is the full width of the device screen in use, or the full width of the banner's parent content. You must know the width of the view to place in the ad, the device width, the parent content width, and applicable safe areas.\n\n\u003c!-- --\u003e\n\n- You may need to update or create new line items to work with adaptive sizes. [Learn more](//support.google.com/admanager/answer/9464128).\n\nOrient inline adaptive banner size\n\nTo preload an inline adaptive banner ad for a specific orientation, use the\nfollowing methods:\n\n- [`AdSize.getPortraitInlineAdaptiveBannerAdSize(Context context, int width)`](/admob/android/early-access/nextgen/reference/com/google/android/libraries/ads/mobile/sdk/banner/AdSize#getPortraitInlineAdaptiveBannerAdSize(android.content.Context,kotlin.Int))\n\n- [`AdSize.getLandscapeInlineAdaptiveBannerAdSize(Context context, int width)`](/admob/android/early-access/nextgen/reference/com/google/android/libraries/ads/mobile/sdk/banner/AdSize#getLandscapeInlineAdaptiveBannerAdSize(android.content.Context,kotlin.Int))\n\nIf your app supports both portrait and landscape views, and you want to preload\nan adaptive banner ad in the current orientation, use\n\n[`AdSize.getCurrentOrientationInlineAdaptiveBannerAdSize(Context context, int width)`](/admob/android/early-access/nextgen/reference/com/google/android/libraries/ads/mobile/sdk/banner/AdSize#getCurrentOrientationInlineAdaptiveBannerAdSize(android.content.Context,kotlin.Int))\n\nThis method loads an ad in the current orientation.\n\nLimit inline adaptive banner height\n\nBy default, inline adaptive banners instantiated without a `maxHeight` value\nhave a `maxHeight` equal to the device height. To limit the inline adaptive\nbanner height, use the\n\n[`AdSize.getInlineAdaptiveBannerAdSize(int width, int maxHeight)`](/admob/android/early-access/nextgen/reference/com/google/android/libraries/ads/mobile/sdk/banner/AdSize#getInlineAdaptiveBannerAdSize(kotlin.Int,kotlin.Int))\n\nmethod.\n\n\u003cbr /\u003e"]]