mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-02-09 22:50:21 +08:00
[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
This commit is contained in:
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user