AdSize

public final class AdSize 

The size of a banner ad.

Summary

Constants

static final int

Constant that will cause the height of the ad to scale based on the height of the device in the current orientation.

static final AdSize

Mobile Marketing Association (MMA) banner ad size (320x50 density-independent pixels).

static final AdSize

A dynamically sized banner that matches its parent's width and expands/contracts its height to match the ad's content after loading completes.

static final AdSize

Interactive Advertising Bureau (IAB) full banner ad size (468x60 density-independent pixels).

static final int
FULL_WIDTH = -1

Constant that will cause the width of the ad to match the width of the device in the current orientation.

static final AdSize

An invalid AdSize that will cause the ad request to fail immediately.

static final AdSize

Large banner ad size (320x100 density-independent pixels).

static final AdSize

Interactive Advertising Bureau (IAB) leaderboard ad size (728x90 density-independent pixels).

static final AdSize

Interactive Advertising Bureau (IAB) medium rectangle ad size (300x250 density-independent pixels).

static final AdSize

This field is deprecated.

Use getCurrentOrientationAnchoredAdaptiveBannerAdSize instead.

static final AdSize

IAB wide skyscraper ad size (160x600 density-independent pixels).

Public fields

final int
final int

Public constructors

AdSize (int width, int height)

Creates a new AdSize .

Public methods

boolean
equals (@ Nullable Object  other)

Compares this AdSize with the specified object and indicates if they are equal.

static AdSize

Returns an AdSize with the given width and a Google-optimized height to create a banner ad.

static AdSize

Returns an AdSize with the given width and a height that is always 0.

int

Returns the height of this AdSize in density-independent pixels.

int
getHeightInPixels ( Context  context)

Returns the height of this AdSize in physical pixels.

static AdSize
getInlineAdaptiveBannerAdSize (int width, int maxHeight)

Returns an AdSize with the given width and a height that is always 0.

static AdSize

Returns an AdSize with the given width and a Google-optimized height to create a banner ad.

static AdSize

Returns an AdSize with the given width and a height that is always 0.

static AdSize

Returns an AdSize with the given width and a Google-optimized height to create a banner ad.

static AdSize

Returns an AdSize with the given width and a height that is always 0.

int

Returns the width of this AdSize in density-independent pixels.

int
getWidthInPixels ( Context  context)

Returns the width of this AdSize in physical pixels.

int
boolean

Returns whether this AdSize is auto-height.

boolean
isFluid ()

Returns whether this AdSize is of fluid size or not.

boolean

Returns whether this AdSize is full-width.

String

Constants

AUTO_HEIGHT

public static final int  AUTO_HEIGHT 
= -2

Constant that will cause the height of the ad to scale based on the height of the device in the current orientation. An AUTO_HEIGHT ad determines its height during initialization of the AdView and never changes after that.

BANNER

public static final  AdSize 
 BANNER 

Mobile Marketing Association (MMA) banner ad size (320x50 density-independent pixels).

FLUID

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.

FULL_BANNER

public static final  AdSize 
 FULL_BANNER 

Interactive Advertising Bureau (IAB) full banner ad size (468x60 density-independent pixels).

FULL_WIDTH

public static final int  FULL_WIDTH 
= -1

Constant that will cause the width of the ad to match the width of the device in the current orientation. A FULL_WIDTH ad determines its width during initialization of the and never changes after that.

INVALID

public static final  AdSize 
 INVALID 

An invalid AdSize that will cause the ad request to fail immediately.

LARGE_BANNER

public static final  AdSize 
 LARGE_BANNER 

Large banner ad size (320x100 density-independent pixels).

LEADERBOARD

public static final  AdSize 
 LEADERBOARD 

Interactive Advertising Bureau (IAB) leaderboard ad size (728x90 density-independent pixels).

MEDIUM_RECTANGLE

public static final  AdSize 
 MEDIUM_RECTANGLE 

Interactive Advertising Bureau (IAB) medium rectangle ad size (300x250 density-independent pixels).

SMART_BANNER

public static final  AdSize 
 SMART_BANNER 

A dynamically sized banner that is full-width and auto-height.

WIDE_SKYSCRAPER

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 fields

height

public final int  height 

width

public final int  width 

Public constructors

AdSize

public  AdSize 
(int width, int height)

Creates a new AdSize .

Parameters
int width

The width of the ad in density-independent pixels.

int height

The height of the ad in density-independent pixels.

Throws
java.lang.IllegalArgumentException

If the width or height is negative.

Public methods

equals

public boolean  equals 
(@ Nullable 
 Object 
 other)

Compares this AdSize with the specified object and indicates if they are equal.

getCurrentOrientationAnchoredAdaptiveBannerAdSize

public static  AdSize 
 getCurrentOrientationAnchoredAdaptiveBannerAdSize 
(
Context  context,
    int width
)

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 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.

Returns
AdSize

An AdSize object. Returns INVALID if the context is null or the device height cannot be determined from the context.

getCurrentOrientationInlineAdaptiveBannerAdSize

public static  AdSize 
 getCurrentOrientationInlineAdaptiveBannerAdSize 
(
Context  context,
    int width
)

Returns an AdSize 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 getAdSize inside the onAdLoaded callback. This ad size is most suitable for ads intended to be displayed inside scrollable content.

getHeight

public int  getHeight 
()

Returns the height of this AdSize in density-independent pixels.

getHeightInPixels

public int  getHeightInPixels 
( Context 
 context)

Returns the height of this AdSize in physical pixels. For fluid size, it returns -1.

getInlineAdaptiveBannerAdSize

public static  AdSize 
 getInlineAdaptiveBannerAdSize 
(int width, int maxHeight)

Returns an AdSize 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 getAdSize inside the onAdLoaded callback. This ad size is most suitable for ads intended to be displayed inside scrollable content.

Parameters
int 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.

getLandscapeAnchoredAdaptiveBannerAdSize

public static  AdSize 
 getLandscapeAnchoredAdaptiveBannerAdSize 
( Context 
 context, int width)

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 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.

Returns
AdSize

An AdSize object. Returns INVALID if the context is null or the device height cannot be determined from the context.

getLandscapeInlineAdaptiveBannerAdSize

public static  AdSize 
 getLandscapeInlineAdaptiveBannerAdSize 
( Context 
 context, int width)

Returns an AdSize 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 getAdSize inside the onAdLoaded callback. This ad size is most suitable for ads intended to be displayed inside scrollable content.

getPortraitAnchoredAdaptiveBannerAdSize

public static  AdSize 
 getPortraitAnchoredAdaptiveBannerAdSize 
( Context 
 context, int width)

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 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.

Returns
AdSize

An AdSize object. Returns INVALID if the context is null or the device height cannot be determined from the context.

getPortraitInlineAdaptiveBannerAdSize

public static  AdSize 
 getPortraitInlineAdaptiveBannerAdSize 
( Context 
 context, int width)

Returns an AdSize 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 getAdSize inside the onAdLoaded callback. This ad size is most suitable for ads intended to be displayed inside scrollable content.

getWidth

public int  getWidth 
()

Returns the width of this AdSize in density-independent pixels.

getWidthInPixels

public int  getWidthInPixels 
( Context 
 context)

Returns the width of this AdSize in physical pixels. For fluid size, it returns -1.

hashCode

public int  hashCode 
()

isAutoHeight

public boolean  isAutoHeight 
()

Returns whether this AdSize is auto-height.

isFluid

public boolean  isFluid 
()

Returns whether this AdSize is of fluid size or not.

isFullWidth

public boolean  isFullWidth 
()

Returns whether this AdSize is full-width.

toString

public  String 
 toString 
()
Create a Mobile Website
View Site in Mobile | Classic
Share by: