The size of a banner ad.
Constant Summary
int | AUTO_HEIGHT | Constant that will cause the height of the ad to scale based on the height of the device in the current orientation. |
int | FULL_WIDTH | Constant that will cause the width of the ad to match the width of the device in the current orientation. |
Field Summary
public static finalAdSize | BANNER | Mobile Marketing Association (MMA) banner ad size (320x50 density-independent pixels). |
public static finalAdSize | FLUID | A dynamically sized banner that matches its parent's width and expands/contracts its height to match the ad's content after loading completes. |
public static finalAdSize | FULL_BANNER | Interactive Advertising Bureau (IAB) full banner ad size (468x60 density-independent pixels). |
public static finalAdSize | INVALID | An invalid AdSize that will cause the ad request to fail immediately. |
public static finalAdSize | LARGE_BANNER | Large banner ad size (320x100 density-independent pixels). |
public static finalAdSize | LEADERBOARD | Interactive Advertising Bureau (IAB) leaderboard ad size (728x90 density-independent pixels). |
public static finalAdSize | MEDIUM_RECTANGLE | Interactive Advertising Bureau (IAB) medium rectangle ad size (300x250 density-independent pixels). |
public static finalAdSize | SEARCH | A special variant of FLUID to be set on
SearchAdView
when loading a
DynamicHeightSearchAdRequest . |
public static finalAdSize | SMART_BANNER | This field is deprecated. Use
getCurrentOrientationAnchoredAdaptiveBannerAdSize(Context, int)
instead. |
public static finalAdSize | WIDE_SKYSCRAPER | IAB wide skyscraper ad size (160x600 density-independent pixels). |
Public Constructor Summary
Public Method Summary
boolean | |
staticAdSize |
getCurrentOrientationAnchoredAdaptiveBannerAdSize(Context
context, int width)
Returns an
AdSize
with the given width and a Google-optimized height to create a banner ad.
|
staticAdSize |
getCurrentOrientationInlineAdaptiveBannerAdSize(Context
context, int width)
Returns an
AdSize
with the given width and a height that is always 0.
|
staticAdSize |
getCurrentOrientationInterscrollerAdSize(Context
context, int width)
Returns an interscroller
AdSize
with the given width and a height that is always 0.
|
int | |
int | |
staticAdSize |
getInlineAdaptiveBannerAdSize(int width, int maxHeight)
Returns an
AdSize
with the given width and a height that is always 0.
|
staticAdSize |
getLandscapeAnchoredAdaptiveBannerAdSize(Context
context, int width)
Returns an
AdSize
with the given width and a Google-optimized height to create a banner ad.
|
staticAdSize |
getLandscapeInlineAdaptiveBannerAdSize(Context
context, int width)
Returns an
AdSize
with the given width and a height that is always 0.
|
staticAdSize |
getLandscapeInterscrollerAdSize(Context
context, int width)
Returns an interscroller
AdSize
with the given width and a height that is always 0.
|
staticAdSize |
getPortraitAnchoredAdaptiveBannerAdSize(Context
context, int width)
Returns an
AdSize
with the given width and a Google-optimized height to create a banner ad.
|
staticAdSize |
getPortraitInlineAdaptiveBannerAdSize(Context
context, int width)
Returns an
AdSize
with the given width and a height that is always 0.
|
staticAdSize |
getPortraitInterscrollerAdSize(Context
context, int width)
Returns an interscroller
AdSize
with the given width and a height that is always 0.
|
int | |
int | |
int |
hashCode()
|
boolean |
isAutoHeight()
Returns whether this
AdSize
is auto-height.
|
boolean | |
boolean |
isFullWidth()
Returns whether this
AdSize
is full-width.
|
String |
toString()
|
Inherited Method Summary
Constants
public static final int AUTO_HEIGHT
Constant that will cause the height of the ad to scale based on the height of the
device in the current orientation. AnAUTO_HEIGHT
ad determines its height
during initialization of theAdView
and never
changes after that.
public static final int FULL_WIDTH
Constant that will cause the width of the ad to match the width of the device in the
current orientation. AFULL_WIDTH
ad determines its width during
initialization of theAdView
and never
changes after that.
Fields
public static final AdSize BANNER
Mobile Marketing Association (MMA) banner ad size (320x50 density-independent pixels).
public static final AdSize FLUID
A dynamically sized banner that matches its parent's width and expands/contracts its height to match the ad's content after loading completes.
public static final AdSize FULL_BANNER
Interactive Advertising Bureau (IAB) full banner ad size (468x60 density-independent pixels).
public static final AdSize INVALID
An invalid AdSize that will cause the ad request to fail immediately.
public static final AdSize LARGE_BANNER
Large banner ad size (320x100 density-independent pixels).
public static final AdSize LEADERBOARD
Interactive Advertising Bureau (IAB) leaderboard ad size (728x90 density-independent pixels).
public static final AdSize MEDIUM_RECTANGLE
Interactive Advertising Bureau (IAB) medium rectangle ad size (300x250 density-independent pixels).
public static final AdSize SEARCH
A special variant of FLUID to be set onSearchAdView
when loading a
DynamicHeightSearchAdRequest
.
public static final AdSize SMART_BANNER
This field is deprecated.
Use
getCurrentOrientationAnchoredAdaptiveBannerAdSize(Context, int)
instead.
A dynamically sized banner that is full-width and auto-height.
public static final AdSize WIDE_SKYSCRAPER
IAB wide skyscraper ad size (160x600 density-independent pixels). This size is currently not supported by the Google Mobile Ads network; this is intended for mediation ad networks only.
Public Constructors
publicAdSize(int width, int height)
Creates a newAdSize
.
Parameters
width | The width of the ad in density-independent pixels. |
---|---|
height | The height of the ad in density-independent pixels. |
Throws
IllegalArgumentException | If the width or height is negative. |
---|
Public Methods
public booleanequals(Objectother)
Compares thisAdSize
with the
specified object and indicates if they are equal.
public staticAdSizegetCurrentOrientationAnchoredAdaptiveBannerAdSize (Contextcontext, int width)
Returns anAdSize
with the
given width and a Google-optimized height to create a banner ad. The size returned will
have an aspect ratio similar toAdSize
,suitable
for anchoring near the top or bottom of your app. The height will never be larger than
15% of the device's current orientation height and never smaller than 50px. This
function always returns the same height for any width / device combination. If the
context is null or the device height cannot be determined from the context,
INVALID
is returned.
public staticAdSizegetCurrentOrientationInlineAdaptiveBannerAdSize (Contextcontext, int width)
Returns anAdSize
with the
given width and a height that is always 0. 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 the
requested orientation. The exact size of the ad returned can be retrieved by calling
BaseAdView.getAdSize()
inside theAdListener.onAdLoaded()
callback. This ad size is most suitable for ads intended to be displayed inside
scrollable content.
public staticAdSizegetCurrentOrientationInterscrollerAdSize(Contextcontext, int width)
Returns an interscrollerAdSize
with the
given width and a height that is always 0. This ad size allows Google servers to choose
an optimal ad height less than or equal to the device's height of current orientation.
The exact size of the ad returned can be retrieved by callingBaseAdView.getAdSize()
inside theAdListener.onAdLoaded()
callback. This ad size is intended for ads displayed inside scrollable content and
below the fold.
public intgetHeight()
Returns the height of thisAdSize
in
density-independent pixels.
public intgetHeightInPixels(Context context)
Returns the height of thisAdSize
in
physical pixels. For fluid size, it returns -1.
public staticAdSizegetInlineAdaptiveBannerAdSize(int width, int maxHeight)
Returns anAdSize
with the
given width and a height that is always 0. This ad size allows Google servers to choose
an optimal ad size with a height less than or equal to the max height given in the
maxHeight parameter. The exact size of the ad returned can be retrieved by calling
BaseAdView.getAdSize()
inside theAdListener.onAdLoaded()
callback. This ad size is most suitable for ads intended to be displayed inside
scrollable content.
Parameters
width | |
---|---|
maxHeight | 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. |
public staticAdSizegetLandscapeAnchoredAdaptiveBannerAdSize(Contextcontext, int width)
Returns anAdSize
with the
given width and a Google-optimized height to create a banner ad. The size returned will
have an aspect ratio similar toBANNER
,
suitable for anchoring near the top or bottom of your app. The height will never be
larger than 15% of the device's height in landscape mode and never smaller than 50px.
This function always returns the same height for any width / device combination. If the
context is null or the device height cannot be determined from the context,
INVALID
is returned.
public staticAdSizegetLandscapeInlineAdaptiveBannerAdSize(Contextcontext, int width)
Returns anAdSize
with the
given width and a height that is always 0. 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. The exact size of the ad returned can be retrieved by calling
BaseAdView.getAdSize()
inside theAdListener.onAdLoaded()
callback. This ad size is most suitable for ads intended to be displayed inside
scrollable content.
public staticAdSizegetLandscapeInterscrollerAdSize(Contextcontext, int width)
Returns an interscrollerAdSize
with the
given width and a height that is always 0. This ad size allows Google servers to choose
an optimal ad height less than or equal to the device's landscape height. The exact
size of the ad returned can be retrieved by callingBaseAdView.getAdSize()
inside theAdListener.onAdLoaded()
callback. This ad size is intended for ads displayed inside scrollable content and
below the fold.
public staticAdSizegetPortraitAnchoredAdaptiveBannerAdSize(Contextcontext, int width)
Returns anAdSize
with the
given width and a Google-optimized height to create a banner ad. The size returned will
have an aspect ratio similar toBANNER
,
suitable for anchoring near the top or bottom of your app. The height will never be
larger than 15% of the device's portrait height and never smaller than 50px. This
function always returns the same height for any width / device combination.
public staticAdSizegetPortraitInlineAdaptiveBannerAdSize(Contextcontext, int width)
Returns anAdSize
with the
given width and a height that is always 0. This ad size allows Google servers to choose
an optimal ad size less than or equal to the height of the screen in portrait
orientation. The exact size of the ad returned can be retrieved by calling
BaseAdView.getAdSize()
inside theAdListener.onAdLoaded()
callback. This ad size is most suitable for ads intended to be displayed inside
scrollable content.
public staticAdSizegetPortraitInterscrollerAdSize(Contextcontext, int width)
Returns an interscrollerAdSize
with the
given width and a height that is always 0. This ad size allows Google servers to choose
an optimal ad height less than or equal to the device's portrait height. The exact size
of the ad returned can be retrieved by callingBaseAdView.getAdSize()
inside theAdListener.onAdLoaded()
callback. This ad size is intended for ads displayed inside scrollable content and
below the fold.
public intgetWidth()
Returns the width of thisAdSize
in
density-independent pixels.
public intgetWidthInPixels(Context context)
Returns the width of thisAdSize
in
physical pixels. For fluid size, it returns -1.
public inthashCode()
public booleanisAutoHeight()
Returns whether thisAdSize
is
auto-height.
public booleanisFluid()
Returns whether thisAdSize
is of
fluid size or not.
public booleanisFullWidth()
Returns whether thisAdSize
is
full-width.