Stay organized with collections
Save and categorize content based on your preferences.
firebase::
gma::
AdSize
#include <types.h>
The size of a banner ad.
Summary
Constructors and Destructors
AdSize
(uint32_t width, uint32_t height)
enum Denotes the orientation of the AdSize
.
enum Denotes the type size object that the AdSize
represents.
Mobile Marketing Association (MMA) banner ad size (320x50 density-independent pixels).
Interactive Advertising Bureau (IAB) full banner ad size (468x60 density-independent pixels).
Taller version of kBanner. Typically 320x100.
Interactive Advertising Bureau (IAB) leaderboard ad size (728x90 density-independent pixels).
Interactive Advertising Bureau (IAB) medium rectangle ad size (300x250 density-independent pixels).
uint32_t
The height of the region represented by this AdSize
.
bool
Comparison operator.
bool
Comparison operator.
The AdSize
type, either standard size or adaptive.
uint32_t
The width of the region represented by this AdSize
.
Creates an AdSize
with the given width and a Google-optimized height to create a banner ad given the current orientation.
A convenience method to return an inline adaptive banner ad size given the current interface orientation.
This ad size is most suitable for banner ads given a maximum height.
Creates an AdSize
with the given width and a Google-optimized height to create a banner ad in landscape mode.
Creates an AdSize
with the given width and the device’s landscape height.
Creates an AdSize
with the given width and a Google-optimized height to create a banner ad in portrait mode.
Creates an AdSize
with the given width and the device’s portrait height.
Public types
Orientation
Orientation
Denotes the orientation of the AdSize
.
AdSize
should reflect the current orientation of the device.
AdSize
will be adaptively formatted in Landscape mode.
AdSize
will be adaptively formatted in Portrait mode.
Type
Type
Denotes the type size object that the AdSize
represents.
An adaptive size anchored to a portion of the screen.
An adaptive size intended to be embedded in scrollable content.
The standard AdSize
type of a set height and width.
Public static attributes
kBanner
const
AdSize
kBanner
Mobile Marketing Association (MMA) banner ad size (320x50 density-independent pixels).
kFullBanner
const
AdSize
kFullBanner
Interactive Advertising Bureau (IAB) full banner ad size (468x60 density-independent pixels).
kLargeBanner
const
AdSize
kLargeBanner
Taller version of kBanner. Typically 320x100.
kLeaderboard
const
AdSize
kLeaderboard
Interactive Advertising Bureau (IAB) leaderboard ad size (728x90 density-independent pixels).
kMediumRectangle
const
AdSize
kMediumRectangle
Interactive Advertising Bureau (IAB) medium rectangle ad size (300x250 density-independent pixels).
Public functions
AdSize
AdSize
(
uint32_t
width
,
uint32_t
height
)
Creates a new AdSize
.
Parameters
width
|
The width of the ad in density-independent pixels.
|
height
|
The height of the ad in density-independent pixels.
|
height
uint32_t
height
()
const
The height of the region represented by this AdSize
.
Value is in density-independent pixels.
operator!=
bool
operator
!=
(
const
AdSize
&
rhs
)
const
operator==
bool
operator
==
(
const
AdSize
&
rhs
)
const
type
Type
type
()
const
The AdSize
type, either standard size or adaptive.
width
uint32_t
width
()
const
The width of the region represented by this AdSize
.
Value is in density-independent pixels.
Public static functions
GetCurrentOrientationAnchoredAdaptiveBannerAdSize
AdSize
GetCurrentOrientationAnchoredAdaptiveBannerAdSize
(
uint32_t
width
)
Creates an AdSize
with the given width and a Google-optimized height to create a banner ad given the current orientation.
Parameters
width
The width of the ad in density-independent pixels.
Returns
an AdSize
with the given width and a Google-optimized height to create a banner ad. The size returned will have an aspect ratio similar to AdSize
, suitable for anchoring near the top or bottom of your app. The exact size of the ad returned can be retrieved by calling AdView::ad_size
once the ad has been loaded.
GetCurrentOrientationInlineAdaptiveBannerAdSize
AdSize
GetCurrentOrientationInlineAdaptiveBannerAdSize
(
int
width
)
A convenience method to return an inline adaptive banner ad size given the current interface orientation.
This AdSize
allows Google servers to choose an optimal ad size with a height less than or equal to the height of the screen in the requested orientation.
Parameters
width
The width of the ad in density-independent pixels.
Returns
an AdSize
with the given width and a height that is always 0. The exact size of the ad returned can be retrieved by calling AdView::ad_size
once the ad has been loaded.
GetInlineAdaptiveBannerAdSize
AdSize
GetInlineAdaptiveBannerAdSize
(
int
width
,
int
max_height
)
This ad size is most suitable for banner ads given a maximum height.
This AdSize
allows Google servers to choose an optimal ad size with a height less than or equal to the max height given in
Parameters
width
|
The width of the ad in density-independent pixels.
|
max_height
|
The maximum height that a loaded ad will have. Must be at least 32 dp, but a maxHeight of 50 dp or higher is recommended.
|
Returns
an AdSize
with the given width and a height that is always 0. The exact size of the ad returned can be retrieved by calling AdView::ad_size
once the ad has been loaded.
GetLandscapeAnchoredAdaptiveBannerAdSize
AdSize
GetLandscapeAnchoredAdaptiveBannerAdSize
(
uint32_t
width
)
Creates an AdSize
with the given width and a Google-optimized height to create a banner ad in landscape mode.
Parameters
width
The width of the ad in density-independent pixels.
Returns
an AdSize
with the given width and a Google-optimized height to create a banner ad. The size returned will have an aspect ratio similar to BANNER, suitable for anchoring near the top or bottom of your app. The exact size of the ad returned can be retrieved by calling AdView::ad_size
once the ad has been loaded.
GetLandscapeInlineAdaptiveBannerAdSize
AdSize
GetLandscapeInlineAdaptiveBannerAdSize
(
int
width
)
Creates an AdSize
with the given width and the device’s landscape height.
This ad size allows Google servers to choose an optimal ad size with a height less than or equal to the height of the screen in landscape orientation.
Parameters
width
The width of the ad in density-independent pixels.
Returns
an AdSize
with the given width and a height that is always 0. The exact size of the ad returned can be retrieved by calling AdView::ad_size
once the ad has been loaded.
GetPortraitAnchoredAdaptiveBannerAdSize
AdSize
GetPortraitAnchoredAdaptiveBannerAdSize
(
uint32_t
width
)
Creates an AdSize
with the given width and a Google-optimized height to create a banner ad in portrait mode.
Parameters
width
The width of the ad in density-independent pixels.
Returns
an AdSize
with the given width and a Google-optimized height to create a banner ad. The size returned will have an aspect ratio similar to BANNER, suitable for anchoring near the top or bottom of your app. The exact size of the ad returned can be retrieved by calling AdView::ad_size
once the ad has been loaded.
GetPortraitInlineAdaptiveBannerAdSize
AdSize
GetPortraitInlineAdaptiveBannerAdSize
(
int
width
)
Creates an AdSize
with the given width and the device’s portrait height.
This ad size allows Google servers to choose an optimal ad size with a height less than or equal to the height of the screen in portrait orientation.
Parameters
width
The width of the ad in density-independent pixels.
Returns
an AdSize
with the given width and a height that is always 0. The exact size of the ad returned can be retrieved by calling AdView::ad_size
once the ad has been loaded.
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-20 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-20 UTC."],[[["\u003cp\u003e\u003ccode\u003efirebase::gma::AdSize\u003c/code\u003e defines the size of a banner ad, including standard and adaptive sizes.\u003c/p\u003e\n"],["\u003cp\u003eIt provides static constants for common ad sizes like \u003ccode\u003ekBanner\u003c/code\u003e, \u003ccode\u003ekFullBanner\u003c/code\u003e, \u003ccode\u003ekLeaderboard\u003c/code\u003e, and more.\u003c/p\u003e\n"],["\u003cp\u003eAdaptive banner sizes are available and can be customized based on orientation and width.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003eAdSize\u003c/code\u003e includes methods to get the width and height of an ad, as well as its orientation and type.\u003c/p\u003e\n"],["\u003cp\u003eDevelopers can create \u003ccode\u003eAdSize\u003c/code\u003e instances with specific dimensions or use pre-defined constants.\u003c/p\u003e\n"]]],["The `AdSize` class defines banner ad dimensions. Key actions include creating an `AdSize` object with specified `width` and `height`, or using predefined static sizes like `kBanner`, `kFullBanner`, etc. You can determine an ad's `orientation` and `type` (standard or adaptive). Adaptive sizes are generated via static functions such as `GetCurrentOrientationAnchoredAdaptiveBannerAdSize` which create Google-optimized ad heights. Methods are provided to compare ad sizes and get their `width` and `height`.\n"],null,[]]