Banner Ads

  • Updated

The following sections show you how to load and then show and hide a banner ad.

Loading a Banner

To load a banner, call createBanner(), passing that method your Ad Unit ID and desired banner position:

var bannerAdUnitId:String = "ad_unit_ID";

public function initializeBannerAds():void
{
  // Banners are automatically sized to 320×50 on phones and 728×90 on tablets
  // You may call the utility method AppLovinMAX.isTablet() to help with view sizing adjustments
  AppLovinMAX.createBanner(bannerAdUnitId, AdViewPosition.BOTTOM_CENTER);

  // Set background or background color for banners to be fully functional
  // The background color is of type uint representing the hex color code of the required color.
  // For example, to set a white background, set the background color to 0xFFFFFF.
  AppLovinMAX.setBannerBackgroundColor(bannerAdUnitId, banner_background_color);
}

The above example creates a banner at the bottom-center of the display (BOTTOM_CENTER). The complete list of position options are:

  • TOP_LEFT
  • TOP_CENTER
  • TOP_RIGHT
  • CENTER_LEFT
  • CENTERED
  • CENTER_RIGHT
  • BOTTOM_LEFT
  • BOTTOM_CENTER
  • BOTTOM_RIGHT

Showing and Hiding a Banner

To show a banner, call showBanner():

AppLovinMAX.showBanner(bannerAdUnitId);

To hide a banner, call hideBanner():

AppLovinMAX.hideBanner(bannerAdUnitId);