首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >反应本机:渲染布局与形式在中心,和灵活的背景

反应本机:渲染布局与形式在中心,和灵活的背景
EN

Stack Overflow用户
提问于 2020-10-26 17:19:33
回答 1查看 143关注 0票数 1

我试着做这样的布局:https://i.stack.imgur.com/NCg1K.png

这就是我所拥有的

代码语言:javascript
复制
<View style={styles.container}>
    <View style={styles.sky}></View>
    <View style={styles.horizon}></View>
    <View style={styles.ground}></View>
</View>

  container: {
    flex: 1,
  },

  sky: {
    flex:15
  },

  ground: {
    flex:7
  },

  horizon: {
    flex:1
  },

但是我不知道应该在中央屏幕上添加表单

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2020-10-27 01:13:05

你可以用绝对实现。

更新

类似于:

代码语言:javascript
复制
import {Dimensions} from "react-native";

class App extends Component {
  render() {
    return (
      <>
      <View style={styles.container}>
        <View style={styles.sky}></View>
        <View style={styles.horizon}></View>
        <View style={styles.ground}></View>
        <View style={styles.center}></View>
      </View>
      </>
    );
  }
}



container: {
    flex: 1
  },
  sky: {
    flex: 15,
    backgroundColor: "red"
  },

  ground: {
    flex: 7,
    backgroundColor: "blue"
  },

  horizon: {
    flex: 1,
    backgroundColor: "green"
  },
  center: {
    position: "absolute",
    width:200,
    height:200,
    left:(Dimensions.get('window').width / 2) - 100,
    top:(Dimensions.get('window').height / 2) - 100,
    justifyContent: "center",
    alignItems: "center",
    backgroundColor: "gray"
  }

代码在线测试

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/64541954

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档