react-native - 在对面 react native View

标签 react-native

我想使用 React Native 在父 View 中将两个 View 放置在彼此相对的两侧。我发现这样做的唯一方法是使用间隔 View :

<View style={styles.parent}>
    <Text style={styles.left}> Left </Text>
    <View style={styles.spacer} />
    <Text style={styles.right}> Right </Text>
</View>

有样式:

const styles = StyleSheet.create({
  parent: {
    flexDirection:'row',
  },
  spacer: {
    flex: 1,
  },
});

我可以向 leftright 添加样式来复制它,而不是使用间隔 View 吗?我发现使用 Prop marginRightright 并没有实现这一点。

最佳答案

为 justifyContent 使用空格

const styles = StyleSheet.create({
     parent: { 
        flexDirection:'row',
        justifyContent:'space-between'
     }, 
});

关于react-native - 在对面 react native View ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36261945/

相关文章:

reactjs - 在 native react 中处理具有 onChangeText 事件属性的对象

android - 如何在 React Native 中构建调试 apk

javascript - 如何将字符串渲染为自定义 React 组件?

javascript - 如何在React Native onPress中隐藏 map 函数中的单个元素?

react-native - 如何在 native react 中读取短信?

javascript - 获取超时 - React Native

ios - React Native 在 View 的一侧添加边框

reactjs - 在模拟器中测试 native firebase 推送通知

react-native - 打印 react native 文本和生成的 QR

javascript - 从 Firestore 中的一个集合中获取所有文档