ReactNative学习笔记1 Flexbox布局

一、比例属性flex和布局方向属性flexDirection

例如三个视图的flex属性值分别为2、4、8,则它们的高度比例为2:4:8。,宽度不指定,默认为全屏的宽度。

class ZLFReactNativeDemo extends Component {
  render() {
    return (
      <View style={styles.container}>
        <View style={styles.style1}></View>
        <View style={styles.style2}></View>
        <View style={styles.style3}></View>
      </View>
    );
  }
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
   flexDirection: column, backgroundColor:
'#00FFFF', }, style1: { flex: 2, backgroundColor: 'red', }, style2: { flex: 4, backgroundColor: 'blue', }, style3: { flex: 8, backgroundColor: 'green', }, });

  

如果要改为横向布局,则只需改父视图的属性flexDirection为row

二、对齐方式属性alignSelf

alignSelf主要有flex-start(对于纵向布局来说是居上,对于横向布局是居左)、 flex-end(对于纵向布局来说是居下,对于横向布局是居右)、 center(居中)、  auto(自由)、 stretch(铺满)几种对齐方式。

三、justifyContent

有如下值、用于约束子视图

 四、alignItems

有如下值、用于约束子视图



转载于:https://my.oschina.net/zhanglinfengzlf/blog/699203

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值