【问题标题】:Images don't render on Android 7.0 (API 24)图像无法在 Android 7.0 (API 24) 上呈现
【发布时间】:2018-08-09 16:26:45
【问题描述】:

我遇到了这个问题,还没有找到解决方案。

事情是这样的:我有这个应用程序,我需要渲染一些图像。是一个流媒体应用,所以必须渲染播放列表缩略图、视频缩略图、播放列表封面等。

我可以在 6.0(api 23)、7.1(api 25) 和 8.0(api 26) 等版本中完美地渲染这些图像。但是,在 7.0(api 24) 版本中,并且仅在此版本中,不会渲染图像

代码是这样构建的:

  • 我收到一组要在地图函数中渲染的播放列表,然后我将每个播放列表发送到一个名为 Horizo​​ntalSquareList 的组件

    <HorizontalSquareList
         key={item.id}
         data={item.playlists}
         horizontal
         showsHorizontalScrollIndicator={false}
         navigation={this.props.navigation}
     />
    
  • 在 Horizo​​ntalSquareList 里面,我有一个叫做 renderImage 的函数

    imageStyle: {
        width: width * 0.27,
        height: 100,
        borderRadius: 2,
    },
    
    function renderImage(item) {
        if (item.thumbnail) {
            return (
                <AsyncImageAnimated
                     key={item.id}
                     style={imageStyle}
                     source={{ uri: item.thumbnail }}
                     resizeMode={'cover'}
                     placeholderColor={'#cfd8dc'}
                     imageKey={`squareImg${item._id}`}
                />
           );
           // else, render an default thumbnail stored in server
     }
    

一个奇怪的事情是,存储在服务器中的默认缩略图会被渲染,但来自 api 的缩略图不会。

这就是问题所在。仅在 android 7.0 上不会渲染这些图像。在其他版本中,它完全没问题。是API的问题吗?代码? Android API?

提前谢谢各位! :)

【问题讨论】:

    标签: android image react-native render


    【解决方案1】:

    如果将来有人来到这里,我设法通过在我收到的图像中将“https”替换为“http”来解决问题。我不知道为什么会这样。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-07-22
      • 2017-07-23
      • 2018-04-27
      • 1970-01-01
      • 2012-09-13
      • 1970-01-01
      相关资源
      最近更新 更多