我想要一个标题,其左侧有一个后退按钮,标题中央有一个文本/标题。
像这样:
<View style={styles.topbar}>
<TouchableOpacity>
<Text style={styles.topbarButton}>{" <"}</Text>
</TouchableOpacity>
<View>
<Text style={styles.topbarText}>Title</Text>
</View>
</View>
我正在尝试在styles.topbar
中使用flex,但我尝试的任何方法似乎都不起作用。
我对 Flex 和 React Native 还很陌生,所以对样式的一些帮助会很棒。
谢谢大家。
最佳答案
我们开始:
<View style={{width:devicewidth,flexDirection:'row',height:40,top:0,position:'absolute'}}>
<TouchableOpacity style={{left:0,position:'absolute',alignItems:'flex- start'}}>
<Text style={styles.topbarButton}>{" <"}</Text>
</TouchableOpacity>
<View style={{justifyContent:'center'}}>
<Text style={styles.topbarText}>Title</Text>
</View>
</View>
上面的代码将在左上角打印后退按钮,在中间打印文本。 Flex方向用于指示按行方向打印的 View 。
关于javascript - 在 native react 中以不同方式对齐两个 child ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41212593/