react-native PixelRatio

/**

* Sample React Native App

* https://github.com/facebook/react-native

* @flow

*/

import React, { Component } from 'react';

import {

AppRegistry,

StyleSheet,

Text,

View,

InteractionManager,

PixelRatio

} from 'react-native';

export default class D20170504 extends Component {

render() {

return (

{

//3

alert(PixelRatio.get());

}}>{'像素密度'}

{

alert(PixelRatio.getPixelSizeForLayoutSize(200));

}}>{'通过逻辑像素来计算物理的像素'}

{

alert(PixelRatio.getFontScale());

}}>{'获得字体缩放的比例'}

);

}

}

const styles = StyleSheet.create({

container: {

flex: 1,

justifyContent: 'center',

alignItems: 'center',

backgroundColor: '#F5FCFF',

},

welcome: {

fontSize: 20,

textAlign: 'center',

margin: 10,

},

instructions: {

textAlign: 'center',

color: '#333333',

marginBottom: 5,

},

});

AppRegistry.registerComponent('D20170504', () => D20170504);

你可能感兴趣的:(react-native PixelRatio)