justifyContent和alignItems

来源:互联网 发布:无损音乐声谱软件 编辑:程序博客网 时间:2024/06/11 22:43

/**
* Sample React Native App
* https://github.com/facebook/react-native
* @flow
*/

import React, {Component} from ‘react’;
import {
AppRegistry,//注册
StyleSheet,//样式
Text,//文本组件
View,//视图组件
Image//图片组件
} from ‘react-native’;

//引入像素点库
var Dimension = require(‘Dimensions’);
export default class Test1 extends Component{

render() {    return(        <View style={mystyle.innerStyle}>            <Text style={{backgroundColor:'red',height:30}}>中国1</Text>            <Text style={{backgroundColor:'green',height:40}}>中国2</Text>            <Text style={{backgroundColor:'yellow',height:50}}>中国3</Text>            <Text style={{backgroundColor:'blue',height:60}}>中国4</Text>        </View>    );}

}

const mystyle = StyleSheet.create({

innerStyle:{
marginTop:50,
// flex:1,
backgroundColor:’#F5FCFF’,
//改变主轴方向
flexDirection:’row’,
//主轴内容的对齐方式
/*
* flex-start 对齐主轴的起点位置
* flex-end 对齐主轴的起点位置
* space-between 平均分配两端对齐
* space-around 平均分配
*
*
* */
justifyContent:’space-around’,

   //设置侧轴   /*    * flex-start     侧轴开始点    * flex-end       侧轴结束点    * center         居中    * space-around   平均分配   * */   alignItems:'center',

}

});
//注册Demo 输出到ios应用
AppRegistry.registerComponent(‘HelloWorld’, () => Test3);

0 0