FlexBox布局的重要属性
2024-09-05 08:17:09
/**
* Sample React Native App
* https://github.com/facebook/react-native
* @flow
*/ import React, { Component } from 'react';
import {
AppRegistry,
StyleSheet,
Text,
View
} from 'react-native'; /*--------------------第一个示例程序------------------*/ class FlexBoxDemo extends Component {
render() {
return (
<View style={styles.container}>
<Text style = {{backgroundColor: 'red',height: }}>第一个</Text>
<Text style = {{backgroundColor: 'green',height: }}>第二个</Text>
<Text style = {{backgroundColor: 'yellow',height: }}>第三个</Text>
<Text style = {{backgroundColor: 'blue',height: }}>第四个</Text>
</View>
);
}
} const styles = StyleSheet.create({
container: { // 注意: 父视图的高度是随子视图而决定的 // 改变主轴的方向
flexDirection: 'row',
backgroundColor: 'purple',
// 距离顶部间距
marginTop:,
// 设置主轴的对齐方式
justifyContent:'center',
// 设置侧轴的对齐方式
alignItems: 'flex-end'
},
}); /*--------------------第二个示例程序------------------*/ class FlexBoxDemo1 extends Component {
render() {
return (
<View style={styles1.container}>
<Text style = {{backgroundColor: 'red',width: }}>第一个</Text>
<Text style = {{backgroundColor: 'green',width: }}>第二个</Text>
<Text style = {{backgroundColor: 'yellow',width: }}>第三个</Text>
<Text style = {{backgroundColor: 'blue',width: }}>第四个</Text>
</View>
);
}
} const styles1 = StyleSheet.create({ container: { // 注意: 父视图的高度是随子视图而决定的 // 改变主轴的方向
flexDirection: 'row',
backgroundColor: 'purple',
// 距离顶部间距
marginTop:,
// 设置主轴的对齐方式
justifyContent:'center',
// 设置侧轴的对齐方式
alignItems: 'flex-end',
// 设置图像换行显示,默认是不换行
flexWrap: 'wrap',
// 决定盒子的宽度 宽度 = 弹性宽度 * (flexGrow / 父View宽度)
flex: , },
}) /*--------------------第三个示例程序------------------*/ class FlexBoxDemo2 extends Component {
render() {
return (
<View style={styles2.container}> <Text style = {{backgroundColor: 'red',height: ,alignSelf: 'flex-start'}}>第一个</Text>
<Text style = {{backgroundColor: 'green',height: }}>第二个</Text>
<Text style = {{backgroundColor: 'yellow',height: }}>第三个</Text>
<Text style = {{backgroundColor: 'blue',height: }}>第四个</Text>
</View>
);
}
} const styles2 = StyleSheet.create({ container: { // 注意: 父视图的高度是随子视图而决定的 // 改变主轴的方向
flexDirection: 'row',
backgroundColor: 'purple',
// 距离顶部间距
marginTop:,
// 设置主轴的对齐方式
justifyContent:'center',
// 设置侧轴的对齐方式
alignItems: 'flex-start',
// 设置图像换行显示,默认是不换行
flexWrap: 'wrap',
// 决定盒子的宽度 宽度 = 弹性宽度 * (flexGrow / 父View宽度)
flex: ,
},
}) AppRegistry.registerComponent('FlexBoxDemo', () => FlexBoxDemo2);
最新文章
- Django 1.7 throws django.core.exceptions.AppRegistryNotReady: Models aren&#39;t loaded yet
- ASP.NET Core--条件处理程序中的依赖注入
- LeetCode-Search a 2D Matrix
- 关于Solr搜索标点与符号的中文分词你必须知道的(mmseg源码改造)
- nodejs的mysql模块学习(五)数据库连接配置之SSL
- hadoop-1.1.2集群搭建
- 【Hadoop代码笔记】Hadoop作业提交之Child启动reduce任务
- POI根据EXCEL模板,修改内容导出新EXCEL (只支持HSSF)
- BZOJ 2754: [SCOI2012]喵星球上的点名
- BaseAdapter导致notifyDataSetChanged()无效的三个原因及处理方法
- Java出现“Error configuring application listener of class...”类似的错误解决
- 老李分享: 并行计算基础&;编程模型与工具 1
- 前端打包文件在nginx上403的解决办法
- c# 反射小Demo
- 剑指offer 3. 链表 从尾到头打印链表
- 什么叫做API?看完你就理解了
- 【MOOC EXP】Linux内核分析实验六报告
- mysql三级连查,左连
- innobackup stream 压缩备份,解压后的qp文件
- mysql中的中文乱码解决方案, 全部是 这篇文章的内容: https://www.52jbj.com/jbdq/18755.html
热门文章
- 自动化测试环境搭建(appium+selenium+python)
- bzoj 1787 &;&; bzoj 1832: [Ahoi2008]Meet 紧急集合(倍增LCA)算法竞赛进阶指南
- 学习elasticsearch(一)linux环境搭建(3)——head插件安装
- 使用html2canvas在手机端独立实现h5页面转图片
- 00-c#与设计模式目录
- hdu 6141 I am your Father!
- ila核数据输出
- msyql round函数隐藏问题
- 北京清北 综合强化班 Day5
- Go中&;和*的区别