Class AdSize

com.yandex.mobile.ads

java.lang.Object ⇽ AdSize

public class AdSize

A class with the size of a banner ad.

Constructors

AdSize(final int width, final int height)

Creates a new object of the AdSize class with the specified width and height of the banner.

Methods

AdSize flexibleSize()

Sets the banner size adjusted to the size of the device screen.

AdSize flexibleSize(final int width)

Sets the banner size with the specified width and maximum height that fits the container size.

AdSize flexibleSize(final int width, final int height)

Specifies the size of the banner depending on the size of the container.

int getHeight()

Returns the banner height in dp (density-independent pixels).

int getHeight(@NonNull final android.content.Context context)

Returns the banner height in dp (density-independent pixels).

int getHeightInPixels(@NonNull final android.content.Context context)

Returns the banner height in pixels.

int getWidth()

Returns the banner width in dp (density-independent pixels).

int getWidth(@NonNull final android.content.Context context)

Returns the banner width in dp (density-independent pixels).

int getWidthInPixels(@NonNull final android.content.Context context)

Returns the banner width in pixels.

AdSize stickySize(final int width)

Returns sticky banner size with the given width.

Fields

final AdSize BANNER_240x400

A banner of the 240x400 size in dp (density-independent pixels).

final AdSize BANNER_300x250

A banner of the 300x250 size in dp (density-independent pixels).

final AdSize BANNER_300x300

A banner of the 300x300 size in dp (density-independent pixels).

final AdSize BANNER_320x100

A banner of the 320x100 size in dp (density-independent pixels).

final AdSize BANNER_320x50

A banner of the 320x50 size in dp (density-independent pixels).

final AdSize BANNER_400x240

A banner of the 400x240 size in dp (density-independent pixels).

final AdSize BANNER_728x90

A banner of the 728x90 size in dp (density-independent pixels).

final int FULL_HEIGHT

The height of the banner is adjusted to the height of the device screen.

final AdSize FULL_SCREEN

A full-screen banner.

final int FULL_WIDTH

The width of the banner is adjusted to the width of the device screen.

Constructor Detail

AdSize

public AdSize (final int width, final int height)

Creates a new object of the AdSize class with the specified width and height of the banner.

Parameters:
width

Banner width in dp (density-independent pixels).

height

Banner height in dp (density-independent pixels).

Method Detail

flexibleSize

public static AdSize flexibleSize ()

Sets the banner size adjusted to the size of the device screen.

Specific banner sizes can be selected in the Partner interface.

Returns:

Banner size adjusted to the size of the device screen.

flexibleSize

public static AdSize flexibleSize (final int width)

Sets the banner size with the specified width and maximum height that fits the container size.

The height of the banner is determined automatically.
Parameters:
width

Banner width in dp (density-independent pixels).

Returns:

Banner size with the width specified and the maximum height selected.

flexibleSize

public static AdSize flexibleSize (final int width, final int height)

Specifies the size of the banner depending on the size of the container.

Parameters:
width

Banner width in dp (density-independent pixels).

height

Banner height in dp (density-independent pixels).

Returns:

The maximum banner size that fits the size of the container.

getHeight

public int getHeight ()

Returns the banner height in dp (density-independent pixels).

Returns:

Banner height in dp (density-independent pixels).

getHeight

public int getHeight (@NonNull final android.content.Context context)

Returns the banner height in dp (density-independent pixels).

If the banner size is set to the full height of the screen (FULL_HEIGHT), the method will return the height of the screen.
Parameters:
context

An object of the Context system class.

Returns:

Banner height in dp (density-independent pixels).

getHeightInPixels

public int getHeightInPixels (@NonNull final android.content.Context context)

Returns the banner height in pixels.

If the banner size is set to the full height of the screen (FULL_HEIGHT), the method will return the height of the screen.
Parameters:
context

An object of the Context system class.

Returns:

Banner height in pixels.

getWidth

public int getWidth ()

Returns the banner width in dp (density-independent pixels).

Returns:

Banner width in dp (density-independent pixels).

getWidth

public int getWidth (@NonNull final android.content.Context context)

Returns the banner width in dp (density-independent pixels).

If the banner size is set to the full width of the screen (FULL_WIDTH), the method will return the width of the screen.
Parameters:
context

An object of the Context system class.

Returns:

Banner width in dp (density-independent pixels).

getWidthInPixels

public int getWidthInPixels (@NonNull final android.content.Context context)

Returns the banner width in pixels.

If the banner size is set to the full width of the screen (FULL_WIDTH), the method will return the width of the screen.
Parameters:
context

An object of the Context system class.

Returns:

Banner width in pixels.

stickySize

public static AdSize stickySize (final int width)

Returns sticky banner size with the given width.

Parameters:
width

The width of the ad container in density-independent pixels (dp).

Returns:

Sticky banner AdSize.

Field Detail

BANNER_240x400

public static BANNER_240x400 = new AdSize(240, 400)

A banner of the 240x400 size in dp (density-independent pixels).

BANNER_300x250

public static BANNER_300x250 = new AdSize(300, 250)

A banner of the 300x250 size in dp (density-independent pixels).

BANNER_300x300

public static BANNER_300x300 = new AdSize(300, 300)

A banner of the 300x300 size in dp (density-independent pixels).

BANNER_320x100

public static BANNER_320x100 = new AdSize(320, 100)

A banner of the 320x100 size in dp (density-independent pixels).

BANNER_320x50

public static BANNER_320x50 = new AdSize(320, 50)

A banner of the 320x50 size in dp (density-independent pixels).

BANNER_400x240

public static BANNER_400x240 = new AdSize(400, 240)

A banner of the 400x240 size in dp (density-independent pixels).

BANNER_728x90

public static BANNER_728x90 = new AdSize(728, 90)

A banner of the 728x90 size in dp (density-independent pixels).

FULL_HEIGHT

public static FULL_HEIGHT = SizeInfo.FULL_HEIGHT

The height of the banner is adjusted to the height of the device screen.

FULL_SCREEN

public static FULL_SCREEN = new AdSize(FULL_WIDTH, FULL_HEIGHT)

A full-screen banner.

FULL_WIDTH

public static FULL_WIDTH = SizeInfo.FULL_WIDTH

The width of the banner is adjusted to the width of the device screen.