AdSize | Android Developers

Quicknav Quicknav
Links

- Google Play Developer Console
- Android Developers Blog
- About Android

Android Sites

- Android.com
- Android Developers
- Android Open Source Project

Language
close

- - About
  - Wear
  - TV
  - Auto
- - Get Started
  - Devices
  - Style
  - Patterns
  - Building Blocks
  - Downloads
  - Videos
- - Training
  - API Guides
  - Reference
  - Tools
  - Google Services
  - Samples
- - Google Play
  - Essentials
  - Get Users
  - Engage & Retain
  - Monetize
  - Tools & Reference
  - Developer Stories

## Results

Loading...
Summary: Constants | Fields | Ctors | Methods | Inherited Methods | [Expand All]
public final class

# AdSize

extends Object

java.lang.Object
↳ | com.google.android.gms.ads.AdSize

## Class Overview

The size of a banner ad.

## Summary

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

Fields
public static final AdSize | BANNER | Mobile Marketing Association (MMA) banner ad size (320x50 density-independent pixels).
public static final AdSize | FULL_BANNER | Interactive Advertising Bureau (IAB) full banner ad size (468x60 density-independent pixels).
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 | SMART_BANNER | 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).

Public Constructors
| AdSize(int width, int height) Create a new `AdSize`.

Public Methods
boolean | equals(Object other) Compares this `AdSize` with the specified object and indicates if they are equal.
int | getHeight() Returns the height of this `AdSize` in density-independent pixels.
int | getHeightInPixels(Context context) Returns the height of this `AdSize` in physical pixels.
int | getWidth() Returns the width of this `AdSize` in density-independent pixels.
int | getWidthInPixels(Context context) Returns the width of this `AdSize` in physical pixels.
int | hashCode()
boolean | isAutoHeight() Returns whether this `AdSize` is auto-height.
boolean | isFullWidth() Returns whether this `AdSize` is full-width.
String | toString()

[Expand] Inherited Methods
From class java.lang.Object
Object | clone()
boolean | equals(Object arg0)
void | finalize()
final Class<?> | getClass()
int | hashCode()
final void | notify()
final void | notifyAll()
String | toString()
final void | wait()
final void | wait(long arg0, int arg1)
final void | wait(long arg0)

## 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. An `AUTO_HEIGHT` ad determines its height during initialization of the `AdView` and never changes after that.

Constant Value: -2 (0xfffffffe)

#### 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. A `FULL_WIDTH` ad determines its width during initialization of the `AdView` and never changes after that.

Constant Value: -1 (0xffffffff)

## Fields

#### public static final AdSize BANNER

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

#### public static final AdSize FULL_BANNER

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

#### 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 SMART_BANNER

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

#### public AdSize (int width, int height)

Create a new `AdSize`.

##### 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 boolean equals (Object other)

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

#### public int getHeight ()

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

#### public int getHeightInPixels (Context context)

Returns the height of this `AdSize` in physical pixels.

#### public int getWidth ()

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

#### public int getWidthInPixels (Context context)

Returns the width of this `AdSize` in physical pixels.

#### public int hashCode ()

#### public boolean isAutoHeight ()

Returns whether this `AdSize` is auto-height.

#### public boolean isFullWidth ()

Returns whether this `AdSize` is full-width.

#### public String toString ()