/**
* Sample React Native App
* https://github.com/facebook/react-native
* @flow
* 2811132560@qq.com
* 说明:项目名为Demo1
* 文件名:Main.js(注意引用)
*/
import React,{ Component } from ‘react’;
//注册一下,你要用什么组件
import {
AppRegistry,
StyleSheet,
PixelRatio,
Text,
View
} from ‘react-native’;
//获取
var Dimensions = require(“Dimensions”);
//var width = Dimensions.get(‘window’).width;
//var height= Dimensions.get(‘window’).height;
var {width,height} = Dimensions.get(‘window’);
var pi = PixelRatio.get();
export default class Demo1 extends Component {
render() { return ( <View style={styles.container}> <Text> 我的屏幕宽度:{width},{'\n'} 我的屏幕高度:{height},{'\n'} 我的屏幕像素:{pi} </Text> ); }
}
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: ‘center’,
alignItems: ‘center’,
backgroundColor: ‘#F5FCFF’,
flexDirection: ‘row’,
height: 100,
padding: 20
},
});
module.exports = Demo1;