Banner & MREC Ads
Banner and MREC ads are rectangular ad formats that occupy a portion of an app’s layout—often positioned at the top or bottom of the screen or placed inline within scrollable content. They remain visible as users interact with the app, allowing for uninterrupted gameplay or usage, and can be refreshed automatically after a set period.
The following sections show you how to load and then show and hide a banner or MREC ad.
Loading a Banner or MREC
To load a banner or MREC, call createBanner()
or createMRec()
.
Pass that method your Ad Unit ID and desired ad view position:
var adUnitId:String = "«ad-unit-ID»";
public function initializeAd():void{ AppLovinMAX.createBanner(adUnitId, AdViewPosition.BOTTOM_CENTER);
// In the case of banner ads, also set the background or background color. // 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(adUnitId, «background-color»);}
var adUnitId:String = "«ad-unit-ID»";
public function initializeAd():void{ AppLovinMAX.createMRec(adUnitId, AdViewPosition.CENTERED);}
The complete list of position options are:
TOP_LEFT
TOP_CENTER
TOP_RIGHT
CENTER_LEFT
CENTERED
CENTER_RIGHT
BOTTOM_LEFT
BOTTOM_CENTER
BOTTOM_RIGHT
Banners are automatically sized to 320×50 on phones or 728×90 on tablets.
MRECs are sized to 300×250 on both phones and tablets.
You can call the utility method AppLovinMAX.isTablet()
to help with view sizing adjustments.
Showing and Hiding a Banner or MREC
To show a banner or MREC, call showBanner()
or showMRec()
:
AppLovinMAX.showBanner(«ad-unit-ID»);
AppLovinMAX.showMRec(«ad-unit-ID»);
To hide a banner or MREC, call hideBanner()
or hideMRec()
:
AppLovinMAX.hideBanner(«ad-unit-ID»);
AppLovinMAX.hideMRec(«ad-unit-ID»);