javascript - 如何在 React Native 中调整图像大小?

标签 javascript css reactjs react-native

我使用的是 logo.png,如果 width: 50height: 50(请参见屏幕截图_1),则在整个图像上只能看到图像的一部分。现在,如果 width: 100height: 50(请参阅屏幕截图_2)可以看到整个图像,但我想要整个图像的尺寸较小,我该怎么做?我尝试了不同的宽度和高度值但不起作用?

原始图像尺寸为:50 X 26

截图1:

enter image description here

截图2:

enter image description here

最佳答案

在图像样式中使用一个名为 resizeMode:'contain' 的属性并提及您的宽度和高度

<Image style={{width:'your_width',height:'your_height',resizeMode:'contain'}} />

希望对你有帮助

关于javascript - 如何在 React Native 中调整图像大小?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52481058/

相关文章:

css - 有没有办法显示 16 :9 web page stretched over more than 3 screens with correct text aspect ratio and without noticeable pixelation?

javascript - 如何在使用 .map() 呈现的按钮之间切换 CSS 类

reactjs - React-Redux connect() 和错误 TS2345

javascript - 使用 AngularJS 添加到 json 对象

javascript - javascript垃圾收集器是否处理全局变量?

html - 如何在我自己的网站上实现 .SCSS?

javascript - Antd提示框悬停后如何消失?

javascript - jQuery uidatepicker 按钮图像不起作用

javascript - jQuery 重构函数

html - 居中滚动文本