PixelDensity


public final class PixelDensity


Represents a pixel density, analogous to the pixel density of a physical display like a computer monitor or TV. It defines the mapping between pixels and physical distance in meters.

Use this class to perform consistent unit conversions between the pixel-based coordinate systems and physical spatial dimensions.

Summary

Public methods

final float
convertMetersToPixels(float meters)

Converts a physical distance in meters to a pixel count using this density.

final float
convertPixelsToMeters(float pixels)

Converts a pixel count to a physical distance in meters using this density.

final float

The number of pixels that correspond to one physical meter.

Public methods

convertMetersToPixels

Added in 1.0.0
public final float convertMetersToPixels(float meters)

Converts a physical distance in meters to a pixel count using this density.

convertPixelsToMeters

Added in 1.0.0
public final float convertPixelsToMeters(float pixels)

Converts a pixel count to a physical distance in meters using this density.

getPixelsPerMeter

Added in 1.0.0
public final float getPixelsPerMeter()

The number of pixels that correspond to one physical meter. Must be a positive and finite value.