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);

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容