我有一张图片,当我想用resizeMode="cover"把它放大时,图片的一部分被剪掉了.如何解决这个问题?

render() {
return (
 <View style={styles.container}>

        <Image
          style={styles.imgStyleGoogle}
          source={{uri: 'my.png'}}
        />
<View>
    )
}

const styles = StyleSheet.create({
  container: {
        flex: 1,
        alignItems:  'center',
        marginLeft: ratio * 5,
        marginRight: ratio * 5,
    },


imgStyleGoogle: {
        flex: 1,
        height: ratio*25,
        width: ratio*100,
        resizeMode:'cover',
    }
})

以下是图片示例:

推荐答案

我找到了解决方案,问题是图像中的flex: 1,我将其从imgStyleGoogle中删除并更改为resizeMode:'contain',并且没有更多的图像被切断.

React-native相关问答推荐

无法读取 @react-native-async-storage/async-storage 的未定义属性setItem

React-Native-Web 错误:rnw_blogpost.bundle.js:1414 Uncaught TypeError: Cannot read properties of undefined (reading 'isBatchingLegacy')

更改所选标签栏元素的底部边框 colored颜色

react-native StyleSheet 属性和选项列表

React Native:错误:找不到资源 android:style/TextAppearance.Material.Widget.Button.Borderless.Colored

带有 react-navigation 的 DrawerNavigation 标头

以编程方式在 React Native 中添加组件

React-Native Android 中隐藏(hide)的元素溢出

React Native 检测点击 View

使用 expo SDK react-native ios 应用程序的 Info.plist 文件

react-navigation模式高度

当前文件夹中的 react-native init

如何更改键盘上的 return按钮?

ReactNative TextInput 不可见 iOS

React Native:如何将 的高度和宽度设置为 容器?

我将如何根据百分比为按钮的宽度设置动画,并且它的背景 colored颜色 也是如此?

使用 React Native 和 Redux 的动画状态管理

为什么我收到警告:函数作为 React 子级无效?

在 React Native 中向组件传递参数

React Native:文本 node 的 Auto宽度