Banner Ad Options
Banner ads offer various advanced features that allow for additional customization and provide the best ad experience. This guide explains how to use the advanced features of banner ads.
Setting Banner Ad Layout Types
For most banner ads, fixed ad sizes such as 320x50, 320x100, 300x250, etc., are predefined. However, some ads provided through the NDA module can optimize the ad size for each device using the BannerViewLayoutType setting to maximize performance.
Regardless of the BannerViewLayoutType setting, it is recommended to set the width and height of the ViewGroup container where the banner ad will be displayed to WRAP_CONTENT to ensure that ads with multiple sizes are displayed without being cropped.
Fixed Size Banner (FIXED)
A type that supports fixed ad sizes. The size of the ViewGroup container where the ad will be displayed must be equal to or larger than the banner.
- Kotlin
- Java
val bannerAdOptions = GfpBannerAdOptions.Builder()
.setBannerViewLayoutType(BannerViewLayoutType.FIXED)
.build()
bannerAdView.setBannerAdOptions(bannerAdOptions)
GfpBannerAdOptions bannerAdOptions = new GfpBannerAdOptions.Builder()
.setBannerViewLayoutType(BannerViewLayoutType.FIXED)
.build();
bannerAdView.setBannerAdOptions(bannerAdOptions);
Fluid Width Banner (FLUID_WIDTH)
The width of the banner ad can expand to match the width of the ViewGroup container where the ad will be displayed.
- Kotlin
- Java
val bannerAdOptions = GfpBannerAdOptions.Builder()
.setBannerViewLayoutType(BannerViewLayoutType.FLUID_WIDTH)
.build()
bannerAdView.setBannerAdOptions(bannerAdOptions)
GfpBannerAdOptions bannerAdOptions = new GfpBannerAdOptions.Builder()
.setBannerViewLayoutType(BannerViewLayoutType.FLUID_WIDTH)
.build();
bannerAdView.setBannerAdOptions(bannerAdOptions);
Fluid Height Banner (FLUID_HEIGHT)
The height of the banner ad can expand to match the height of the ViewGroup container where the ad will be displayed.
- Kotlin
- Java
val bannerAdOptions = GfpBannerAdOptions.Builder()
.setBannerViewLayoutType(BannerViewLayoutType.FLUID_HEIGHT)
.build()
bannerAdView.setBannerAdOptions(bannerAdOptions)
GfpBannerAdOptions bannerAdOptions = new GfpBannerAdOptions.Builder()
.setBannerViewLayoutType(BannerViewLayoutType.FLUID_HEIGHT)
.build();
bannerAdView.setBannerAdOptions(bannerAdOptions);
Fluid Banner (FLUID)
The width and height of the banner ad can expand to match the width and height of the ViewGroup container where the ad will be displayed.
- Kotlin
- Java
val bannerAdOptions = GfpBannerAdOptions.Builder()
.setBannerViewLayoutType(BannerViewLayoutType.FLUID)
.build()
bannerAdView.setBannerAdOptions(bannerAdOptions)
GfpBannerAdOptions bannerAdOptions = new GfpBannerAdOptions.Builder()
.setBannerViewLayoutType(BannerViewLayoutType.FLUID)
.build();
bannerAdView.setBannerAdOptions(bannerAdOptions);
Passing Meta Information
This setting is used to pass predefined key/value pairs for banner ad creatives, typically for theme settings. Refer to the table below for the values and descriptions that can be set for the theme key.
theme | description |
---|---|
light | The banner ad creative is always rendered in LIGHT mode. |
dark | The banner ad creative is always rendered in DARK mode. |
system | The banner ad creative is rendered according to the device's DARK mode setting. |
The theme setting can only be applied to certain S2S banner ads provided through the NDA module. Please contact the NAM administrator if you wish to apply this setting.
The following example demonstrates how to render the banner ad creative in DARK mode at all times.
- Kotlin
- Java
val bannerAdOptions = GfpBannerAdOptions.Builder()
...
.setHostParam(
HostParam.Builder()
.addMetaParam("theme", "dark") // In NDA ad, some ad creative support dark mode. This value will be apply in that creative.
.build()
)
.build()
bannerAdView.setBannerAdOptions(bannerAdOptions)
GfpBannerAdOptions bannerAdOptions = new GfpBannerAdOptions.Builder()
...
.setHostParam(
new HostParam.Builder()
.addMetaParam("theme", "dark") // In NDA ad, some ad creative support dark mode. This value will be apply in that creative.
.build()
)
.build();
bannerAdView.setBannerAdOptions(bannerAdOptions);
Timeout Settings
The timeout value for ads requested through GfpBannerAdView can be globally set via SdkProperties. However, if you want to set a timeout for a single ad request, you can use the setTimeoutMillis() method of GfpBannerAdView as shown in the example below.
The following example demonstrates setting the timeout value for a single ad request to 10 seconds for a specific GfpBannerAdView. When the timeout value for a single ad request is set as shown below, the globally set timeout value is ignored.
If no timeout value is set in SdkProperties or GfpBannerAdView, the default timeout value of 60 seconds is applied.
- Kotlin
- Java
bannerAdView.setTimeoutMillis(10_000L)
bannerAdView.setTimeoutMillis(10_000L);