使用 resizeMode="contain" 时,图像无法在 react-native 中呈现道具? [英] Images fail to render in react-native when using resizeMode="contain" props?
问题描述
我正在使用 reactnative 来制作一个 android 应用程序.我正在使用本机路由器通量来在应用程序的不同页面之间导航.(正如文档通过调用 Actions.PAGENAME()
所指示的那样).
I am using reactnative for making an android app. I am using react native router flux for navigation between different pages of the app. (As the doc indicates by calling Actions.PAGENAME()
).
当每个页面最初加载时一切都很好,但在导航或浏览应用程序的不同页面一段时间后出现问题,图像开始消失.在这种情况下,我使用图像的地方是空白的.同样,当我在调试模式下多次重新加载应用程序时,也会发生同样的事情.
When each page loads initially everything was quite good but the problem arises after navigating or browsing through different pages of the app for some time , Images starting to disappear. The places where I used image are blank in that case. Also when I reload the app several times in debug mode, same thing happen.
经过几天的反复试验,我发现这个问题是在我使用 < 时引起的.带有道具
组件.如果我使用 resizeMode="contain"
的图像 >resizeMode="cover"
,则问题不存在.但是,我需要这些道具才能正确放置图像,这似乎是唯一的选择.
After trying for couple of days with lots of trial and error I had found that this issue is caused when I use < Image >
component with props resizeMode="contain"
. If I use resizeMode="cover"
, the issue is not there. However, I need that props on order to place the image properly and it seems the only option.
你们中有人遇到过和我一样的问题吗?有没有办法解决这个问题?如果不是,那么替代方案是什么?
Does any of you faced the same problem I am facing no ? Is there any solution to the problem? If not, then what is the alternative?
推荐答案
尝试在您的 android manifest 应用程序标签中添加 android:largeHeap="true".就像下面描述的 stackoverflow-answer 一样.这似乎可以创造更好的性能,并且可以解决您的图片加载问题.
Try to add android:largeHeap="true" in your android manifest application tag. Like the following stackoverflow-answer described. This seems to create better performance and may solve your image loading issues.
这篇关于使用 resizeMode="contain" 时,图像无法在 react-native 中呈现道具?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!