【问题标题】:React-Native Android: Unable to display static imagesReact-Native Android:无法显示静态图像
【发布时间】:2015-12-17 16:30:57
【问题描述】:

我正在尝试使用 react native 在我的 android 应用程序中显示静态图像(ic_launcher)。我得到一个黑色的回应。没有错误。只是一个空白视图,好像资源不存在。我能够显示来自网络的图像。

【问题讨论】:

标签: react-native


【解决方案1】:

您的 ic_launcher 文件可能位于 android/app/src/main/res/mipmap-xxx 目录中。尝试将其移动到 android/app/src/main/res/drawable-xxx 目录。

【讨论】:

  • 工作就像一个魅力。谢谢
【解决方案2】:
  • \安卓
  • |----\app
  • |----|---\src
  • |----|---|----\main
  • |----|---|----|---\res
  • |----|---|----|---|---\drawable
  • |----|---|----|---|---|---\ic_launcher.png

【讨论】:

    【解决方案3】:

    您应该使用require('image!img_name') 作为source 组件的source 属性。 在https://github.com/facebook/react-native/blob/master/Examples/UIExplorer/ImageExample.js#L84 此处查看示例应用程序,其资源位于https://github.com/facebook/react-native/tree/master/Examples/UIExplorer/android/app/src/main/res/drawable 下

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-12-12
      • 2016-11-02
      • 2016-12-20
      • 1970-01-01
      • 2022-01-01
      • 1970-01-01
      • 2019-05-29
      • 1970-01-01
      相关资源
      最近更新 更多