我正在尝试对齐包含在 React Native 中的文本元素中的文本和图像。
我想让它对齐,这样它就均匀了。
这是我目前拥有的代码:
<Text>
<Text
key={i}
onPress={() => this.updateCurrentFilter(i)}
style={{
paddingLeft: 10,
fontFamily: "Montserrat-Regular",
fontSize: 12,
}}
>{v.filter_name}</Text>
<Image
source={require('../assets/outline_toggle_off_black_18dp.png')}
style={{
width: 25,
height: 25,
color: 'black',
resizeMode: 'contain',
}}
/>
</Text>
Run Code Online (Sandbox Code Playgroud)
像这样的东西应该有效。目前尚不清楚为什么要将外部级别包装在字段中Text而不是字段中View
<Text>
<View style={{flexDirection:'row', alignItems:'center'}}>
<Text style={{....}}}>foo</Text>
<Image ... />
</View>
</Text>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
6464 次 |
| 最近记录: |