|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.google.ads.AdSize
public class AdSize
The different sizes of ads supported.
Field Summary | |
---|---|
static int |
AUTO_HEIGHT
A flag used to denote that an ad's height will be determined automatically. |
static AdSize |
BANNER
Size of MMA standard banner ad. |
static int |
FULL_WIDTH
A flag used to denote that an ad is full-width. |
static AdSize |
IAB_BANNER
Size of IAB standard full banner ad. |
static AdSize |
IAB_LEADERBOARD
Size of IAB standard leaderboard ad. |
static AdSize |
IAB_MRECT
Side of IAB standard medium rectangle ad. |
static AdSize |
IAB_WIDE_SKYSCRAPER
Size of skyscraper ad. |
static int |
LANDSCAPE_AD_HEIGHT
Constant for height of ads in landscape mode. |
static int |
LARGE_AD_HEIGHT
Constant for height of ads on large devices in both orientations. |
static int |
PORTRAIT_AD_HEIGHT
Constant for height of ads in portrait mode. |
static AdSize |
SMART_BANNER
A dynamically sized banner that is full-width and auto-height. |
Constructor Summary | |
---|---|
AdSize(int width,
int height)
Constructs a custom AdSize . |
Method Summary | |
---|---|
static AdSize |
createAdSize(AdSize adSize,
Context context)
DO NOT USE THIS FACTORY. |
boolean |
equals(Object other)
Compares two AdSizes. |
AdSize |
findBestSize(AdSize... options)
Chained method to find the most appropriate size for this AdSize. |
int |
getHeight()
Returns the height of the AdSize . |
int |
getHeightInPixels(Context context)
Returns the height of the AdSize in physical pixels. |
int |
getWidth()
Returns the width of the AdSize . |
int |
getWidthInPixels(Context context)
Returns the width of the AdSize in physical pixels. |
int |
hashCode()
Returns an integer hash code for this AdSize. |
boolean |
isAutoHeight()
Returns whether AdSize is auto height. |
boolean |
isCustomAdSize()
Returns whether AdSize is for a custom-sized ad. |
boolean |
isFullWidth()
Returns whether AdSize is full width. |
boolean |
isSizeAppropriate(int width,
int height)
Reports whether the provided dimensions are appropriate for an ad of the requested size. |
String |
toString()
Returns the AdSize as a String . |
Methods inherited from class java.lang.Object |
---|
getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final int FULL_WIDTH
For example, new AdSize(AdSize.FULL_WIDTH,
AdSize.SMARTPHONE_PORTRAIT_AD_HEIGHT)
might become 360x50 dip wide in
portrait mode. If the device is rotated to landscape mode and the app
handles its own configuration changes (by adding configChanges to the
AndroidManifest.xml file), the ad will continue to be 360x50 dip in
landscape mode.
If instead, the app tears down and recreates the
Activity
(the default behavior on Android), the AdSize
will be reinitialized and will determine a new width. So in the above
example, the ad might become 640x50 dip wide in landscape mode to take up
the full-width of the device.
public static final int AUTO_HEIGHT
For example, new AdSize(AdSize.FULL_WIDTH, AdSize.AUTO_HEIGHT)
might become 360x50 dip wide in portrait mode on a 720x1280 pixel screen
with a density of 2.0. If the device is rotated to landscape mode and the
app handles its own configuration changes (by adding configChanges to the
AndroidManifest.xml file), the ad will continue to be 360x50 dip in
landscape mode.
If instead, the app tears down and recreates the
Activity
(the default behavior on Android), the
AdSize will be reinitialized and will determine a new height (and width
due to FULL_WIDTH). So in the above example, the ad might become 640x32
dip wide in landscape mode to take up the full-width of the device and
less height.
On a screen 400 dip tall or less, the ad will be 32 dip tall. On a screen 720 dip tall or less, the ad will be 50 dip tall. Otherwise, it will be 90 dip tall. As a result, most phones will be 32 dip tall in landscape and 50 dip tall in portrait. Most tablets will be 90 dip tall in both orientations.
public static final int LANDSCAPE_AD_HEIGHT
SMART_BANNER
.
public static final int PORTRAIT_AD_HEIGHT
SMART_BANNER
.
public static final int LARGE_AD_HEIGHT
SMART_BANNER
.
public static final AdSize SMART_BANNER
FULL_WIDTH
and AUTO_HEIGHT
for more details regarding the algorithms used to
generate this AdSize
.
public static final AdSize BANNER
public static final AdSize IAB_MRECT
public static final AdSize IAB_BANNER
public static final AdSize IAB_LEADERBOARD
public static final AdSize IAB_WIDE_SKYSCRAPER
Constructor Detail |
---|
public AdSize(int width, int height)
AdSize
.
WARNING: Be cautious using this constructor because it may affect your fill
rate. Consider using one of the predefined AdSize constants instead.
width
- the width of the AdSize
in density-independent pixels.height
- the height of the AdSize
in density-independent pixels.Method Detail |
---|
public static AdSize createAdSize(AdSize adSize, Context context)
AdSize
CONSTRUCTOR.
Factory for AdSize
. For normal sized ads, we return an ad with the
same properties as the original. For smart sized ads, we return an ad
based on the application's context. If a context is not included, or is
null, we return to using a 320x50 sized ad.
adSize
- the AdSize
object from which to copy attributes.context
- the context of the AdSize
.public boolean equals(Object other)
equals
in class Object
public int hashCode()
hashCode
in class Object
public int getWidth()
AdSize
.
public int getHeight()
AdSize
.
public boolean isFullWidth()
AdSize
is full width.
AdSize
is full width.public boolean isAutoHeight()
AdSize
is auto height.
AdSize
is auto height.public boolean isCustomAdSize()
AdSize
is for a custom-sized ad.
public String toString()
AdSize
as a String
.
toString
in class Object
public int getWidthInPixels(Context context)
AdSize
in physical pixels.
public int getHeightInPixels(Context context)
AdSize
in physical pixels.
public boolean isSizeAppropriate(int width, int height)
width
- Width of the space to check.height
- Height of the space to check.
true
if the given size is appropriate, false
otherwise.public AdSize findBestSize(AdSize... options)
Usage:
MySize m = adSize.findBestSize( new AdSize.SizeOption(100, 20, MySize.MiniBanner), new AdSize.SizeOption(320, 45, MySize.Banner), new AdSize.SizeOption(480, 100, MySize.HugeBanner));
options
- AdSize
instances defining ad size representations
and the object that represents them.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |