react-native 常用flex布局

1,竖向按比例布局

409B15FC-9B22-4966-9F6E-8A4B1AA44949.png

代码:

<View style={{flex:1,alignItems:'center'}}>
        <View style={{flex:1,backgroundColor:'#000',width:width*5/6}}></View>
        <View style={{flex:2,backgroundColor:'#ff4a2e',width:width*5/6}}></View>
        <View style={{flex:3,backgroundColor:'#6bff4f',width:width*5/6}}></View>
        <View style={{flex:4,backgroundColor:'#3a48ff',width:width*5/6}}></View>
</View>

2,横向按比例布局

48460300-6628-4A5A-9C15-FF2CF88AC9B5.png

代码:

<View style={{flex:1,flexDirection:'row'}}>
        <View style={{flex:1,backgroundColor:'#000',height:height*5/6}}></View>
        <View style={{flex:2,backgroundColor:'#ff4a2e',height:height*5/6}}></View>
        <View style={{flex:3,backgroundColor:'#6bff4f',height:height*5/6}}></View>
        <View style={{flex:4,backgroundColor:'#3a48ff',height:height*5/6}}></View>
      </View>
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容