Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit b7253dc

Browse files
author
Martin Konicek
committed
[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
1 parent 09bb761 commit b7253dc

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

Libraries/Utilities/PixelRatio.js

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,11 @@ var Dimensions = require('Dimensions');
2020
*
2121
* ### Displaying a line that's as thin as the device permits
2222
*
23-
* A width of 1 is actually pretty thick on an iPhone 4+, we can do one that's
24-
* thinner using a width of `1 / PixelRatio.get()`. It's a technique that works
25-
* on all the devices independent of their pixel density.
23+
* A width of 1 is actually pretty thick on devices with high pixel density
24+
* (such as iPhone 4+ and many Android devices), we can make one that's
25+
* thinner using a width of `1 / PixelRatio.get()`.
26+
* It's a technique that works on all the devices independent of their
27+
* pixel density.
2628
*
2729
* ```
2830
* style={{ borderWidth: 1 / PixelRatio.get() }}
@@ -46,12 +48,18 @@ class PixelRatio {
4648
/**
4749
* Returns the device pixel density. Some examples:
4850
*
51+
* - PixelRatio.get() === 1
52+
* - mdpi Android devices (160 dpi)
53+
* - PixelRatio.get() === 1.5
54+
* - hdpi Android devices (240 dpi)
4955
* - PixelRatio.get() === 2
5056
* - iPhone 4, 4S
5157
* - iPhone 5, 5c, 5s
5258
* - iPhone 6
59+
* - xhdpi Android devices (320 dpi)
5360
* - PixelRatio.get() === 3
5461
* - iPhone 6 plus
62+
* - xxhdpi Android devices (480 dpi)
5563
* - PixelRatio.get() === 3.5
5664
* - Nexus 6
5765
*/
@@ -68,6 +76,7 @@ class PixelRatio {
6876
*
6977
* Currently this is only implemented on Android and reflects the user preference set in
7078
* Settings > Display > Font size, on iOS it will always return the default pixel ratio.
79+
* @platform android
7180
*/
7281
static getFontScale(): number {
7382
return Dimensions.get('window').fontScale || PixelRatio.get();

0 commit comments

Comments
 (0)