css - 在本机反应中将 TouchableOpacity 与 flexbox 对齐
问题描述
我TouchableOpacity
在一行中对齐图标时遇到问题。
这是我的代码:
<View style={styles.container12}>
<View style={styles.sociaContainer}>
<TouchableOpacity style={styles.socialIcon}
onPress={() => Linking.openURL('https://www.facebook.com/JelenPivoBiH/?brand_redir=28032575448')}>
<Icon name="facebook" size={50} color="#fff" />
</TouchableOpacity>
<TouchableOpacity style={styles.socialIcon}
onPress={() => Linking.openURL('https://www.instagram.com/jelenpivo/')}>
<Icon name="instagram" size={50} color="#fff" />
</TouchableOpacity>
</View>
<Image style={styles.headerImage} source={require('../assets/images/Picture-app2.png')} />
</View>
const styles = StyleSheet.create({
socialIcon: {
alignItems: 'center',
flexDirection: 'row',
marginLeft: 50,
},
container12: {
flex: 1,
flexDirection: 'row',
marginTop: 20,
},
});
我尝试了所有我知道的与 flex 的组合,但它不起作用。对于每个其他元素,它都在工作,但在这种情况下不是。
这是结果:
我要他们排成一排。
解决方案
只需简单的样式更改即可使您的代码正常工作。检查这个
<View style={styles.container12}>
{/* <View style={styles.sociaContainer}> */}
<View style={styles.container12}>
<TouchableOpacity style={styles.socialIcon}
onPress={() => Linking.openURL('https://www.facebook.com/JelenPivoBiH/?brand_redir=28032575448')}>
<Icon name="facebook" size={50} color="#fff" />
</TouchableOpacity>
<TouchableOpacity style={styles.socialIcon}
onPress={() => Linking.openURL('https://www.instagram.com/jelenpivo/')}>
<Icon name="instagram" size={50} color="#fff" />
</TouchableOpacity>
</View>
<Image style={styles.headerImage} source={require('../assets/images/Picture-app2.png')} />
</View>
希望这会帮助你。
推荐阅读
- asp.net-core - 每个用户的 asp.net core 2.1 自定义默认路由
- angularjs - 点击深层链接总是会重定向到 App Store
- mysql - 如何将 mysql 查询转换为 laravel 查询生成器?
- css - 在输入框中使用图像作为图标
- javascript - 如何提高滚动魔术的速度
- r - Rvest 中的多个页面
- angular - Angular 中的复选框不接受提交时的最新值
- javascript - 谷歌图表 - 缺少列和重复 x 轴标签
- angular - 无需订阅即可加入 Firebase
- jquery - bootstrap3 边距/填充影响 jsPlumb 的端点