如图所示,如果三个红色视图已添加到父视图中.现在我想添加另一个蓝色视图,它可以填充剩余空间.我该如何设置样式?

在此处输入图像描述

推荐答案

你可以试试这个;

<View style={{flex:1,backgroundColor:'white'}}>
  <View style={{justifyContent:'space-around'}}>
    <View style={{height:50,alignSelf:'stretch',backgroundColor:'pink',margin:5}}/>  
    <View style={{height:50,alignSelf:'stretch',backgroundColor:'pink',marginHorizontal:5}}/>  
    <View style={{height:50,alignSelf:'stretch',backgroundColor:'pink',margin:5}}/>  
  </View>
  <View style={{flex:1,alignItems:'center',justifyContent:'center',alignSelf:'stretch',backgroundColor:'blue',margin:5}}>
    <Text style={{color:'white',fontWeight:'bold'}}>
      View
    </Text>
  </View>
</View>

enter image description here

React-native相关问答推荐

在我的 React Native 应用程序中获取数据返回 [object Object] 而不是 renderSectionHeader

嵌套的FlatList内的Incorrect Padding

根据搜索字符串中的每个字母过滤数组

在向后滑动时执行操作(react-navigation )

你使用 react native 应该学习 react.js 吗?

从 .apk 到 .aab 的本地构建版本react,如何将应用程序发送给客户端?

React Native:约束 Animated.Value

react native 中 componentDidMount 和 componentDidUpdate 有什么区别

react native foreach 循环

如何更改 React Native(android)应用程序的远程推送通知图标

React Native 开发中的/ios/index/DataStore文件夹是什么

为了回调 URL 的目的,在 Expo 中运行的 React Native 元素的 info.plist 在哪里?

Undefined 不是判断 this.state.* 的对象

React-Native Android - 找不到 com.android.tools:common

React Navigation TabNavigator:在选项卡更改时重置上一个选项卡

无法解析模块 react/lib/ReactUpdates

在 Android React Native 应用程序中正确使用 Intl

如何将本地文本文件加载到 React Native Project 中的字符串变量中?

Tools > Android 菜单在 Android Studio 中不存在

React-Native 水平滚动视图分页:预览下一页/卡片