~~~
// 实例4 获取屏幕的宽高分辨率
var Dimensions = require('Dimensions');
var {width,height,scale} =Dimensions.get('window');
class AwesomeProject4 extends Component {
render() {
return (
<View style={styles4.container}>
<Text style={{color:'#ccc'}}>
屏幕的宽:{width+'\n'}
屏幕的高:{height+'\n'}
屏幕的分辨率:{scale+'\n'}
</Text>
</View>
);
}
}
const styles4 = StyleSheet.create({
container: {
flex:1,
height:100,
flexDirection: 'row',
backgroundColor: '#f4f3f3',
justifyContent:'center',//主轴线的对齐方式
alignItems:'center', //交叉轴上如何对齐
flexWrap:'wrap'//如果一条轴线排不下,如何换行
},
~~~