PixelRatio

PixelRatio class gives access to the device pixel density.

import { PixelRatio } from 'react-native';

API #

Static methods #

get () => number

Returns the device pixel density as a number.

getFontScale () => number

On web this returns the device pixel ratio as a number.

getPixelSizeForLayoutSize (number) => number

Converts a layout size (dp) to pixel size (px). Guaranteed to return an integer number.

roundToNearestPixel (number) => number

Rounds a layout size (dp) to the nearest layout size that corresponds to an integer number of pixels. For example, on a device with a PixelRatio of 3, PixelRatio.roundToNearestPixel(8.4) = 8.33, which corresponds to exactly (8.33 * 3) = 25 pixels.

Updated
Edit
React Native for WebCopyright © Nicolas Gallagher and Facebook Inc.