justifyContent 不适用于 View React Native

justifyContent not applying in View React Native

出于某种原因,在此视图中,证明内容标记不适用于我的视图?我试过在 modalScreen 视图中应用它,但这也不起作用。有什么想法吗?

function BottomPopup() {
  return (
    <View style={styles.modalScreen}>
      <View style={styles.topbar}>
        <MaterialCommunityIcons name="arrow-left" size={24} color="black" />
        <Text>Create Post</Text>
        <MaterialCommunityIcons name="content-save" size={24} color="black" />
      </View>
      <View>
        <Text>hey</Text>
        <Text>hey</Text>
      </View>
    </View>
  );
}

const styles = StyleSheet.create({
  modalScreen: {
    alignItems: "center",
  },
  topbar: {
    display: "flex",
    flexDirection: "row",
    justifyContent: "space-around",
  },
});

在 modalScreen 样式中添加 flex:1,例如 Snack.IO

我必须添加 width: "100%" 然后它起作用了

import { Dimensions } from 'react-native';
const { width, height } = Dimensions.get('window');

const styles = StyleSheet.create({
  modalScreen: {
    flex:1,
    alignItems: "center",
    backgroundColor: "yellow",
  },
  topbar: {
    width: width,
    flexDirection: "row",
    justifyContent: "space-around",
    backgroundColor: "green",
  },
});