react-native - 图像未在其容器 React Native 顶部对齐
问题描述
我正在尝试在其容器顶部对齐图像以响应本机,尤其是在横向上。
<View style={{flexDirection: 'row', justifyContent: 'center',alignItems: 'center'}}>
<View style={{flex:1,backgroundColor: 'green'}} >
<Image resizeMode='contain'style={{ flex:1,width:"100%",height:"100%"}} source={{uri:"https://www.tageblatt.lu/wp-content/uploads/2020/09/250112_cx__cy__cw__ch_-1-739x493.jpeg"}} />
</View>
<View style={{width:"15%",backgroundColor: 'blue' }}>
<Text style={{color:"white",padding:7}}>{caption}</Text>
</View>
</View>
这段代码的输出是:
在风景上:
所需的输出是:
如果我在我的编辑器上按 control+s(保存),我会进入横向。 我遵循这个问题,但对我没有解决方案。我也为 resizeMode 尝试了不同的值。
解决方案
你试过改变resizeMode
吗?
<Image resizeMode='cover' ... />
推荐阅读
- azure-active-directory - AADB2C99002 错误。没有注册政策的 B2C 登录政策?
- logstash - Logstash - 错误“应为 [ \t\r\n]、“#”之一
- visualization - 离散和连续数据的可视化
- postgresql - 在 OneToOne 关系 typeorm postgres 的两边都有 RelationID
- laravel - Ratched Websocket 连接关闭
- javascript - 使用 Javascript 从 URL 中获取查询字符串值
- javascript - 声明的第一个类属性中的 ESLint 解析错误
- javascript - 在 javascript 中实现 drop it 功能但需要的答案没有得到它
- google-apps-script - 有什么方法可以为 Gmail 帐户创建的每个 Google 表单做一个吗?
- android - 如何在 Jetpack Compose 中将触摸事件分派给父可组合项