From b7253dc6045ce9cb37b7f6611a58da37e9746dd2 Mon Sep 17 00:00:00 2001 From: Martin Konicek Date: Mon, 27 Jul 2015 09:25:19 -0700 Subject: [PATCH] [ReactNative] PixelRatio docs Summary: Update docs for `PixelRatio` in preparation for open sourcing React Native for Android. See http://stackoverflow.com/questions/11581649/about-android-image-and-asset-sizes --- Libraries/Utilities/PixelRatio.js | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/Libraries/Utilities/PixelRatio.js b/Libraries/Utilities/PixelRatio.js index 7660fad30..940890cce 100644 --- a/Libraries/Utilities/PixelRatio.js +++ b/Libraries/Utilities/PixelRatio.js @@ -20,9 +20,11 @@ var Dimensions = require('Dimensions'); * * ### Displaying a line that's as thin as the device permits * - * A width of 1 is actually pretty thick on an iPhone 4+, we can do one that's - * thinner using a width of `1 / PixelRatio.get()`. It's a technique that works - * on all the devices independent of their pixel density. + * A width of 1 is actually pretty thick on devices with high pixel density + * (such as iPhone 4+ and many Android devices), we can make one that's + * thinner using a width of `1 / PixelRatio.get()`. + * It's a technique that works on all the devices independent of their + * pixel density. * * ``` * style={{ borderWidth: 1 / PixelRatio.get() }} @@ -46,12 +48,18 @@ class PixelRatio { /** * Returns the device pixel density. Some examples: * + * - PixelRatio.get() === 1 + * - mdpi Android devices (160 dpi) + * - PixelRatio.get() === 1.5 + * - hdpi Android devices (240 dpi) * - PixelRatio.get() === 2 * - iPhone 4, 4S * - iPhone 5, 5c, 5s * - iPhone 6 + * - xhdpi Android devices (320 dpi) * - PixelRatio.get() === 3 * - iPhone 6 plus + * - xxhdpi Android devices (480 dpi) * - PixelRatio.get() === 3.5 * - Nexus 6 */ @@ -68,6 +76,7 @@ class PixelRatio { * * Currently this is only implemented on Android and reflects the user preference set in * Settings > Display > Font size, on iOS it will always return the default pixel ratio. + * @platform android */ static getFontScale(): number { return Dimensions.get('window').fontScale || PixelRatio.get();