android - 在 React Native Image 组件中加载本 map 片

标签 android reactjs react-native

我正在开发一个在 Android 上使用 React Native 的应用程序。我想在屏幕上放置一些图像组件,并用一些本地镜像文件加载它们。有人可以提供我应该放置文件的目录(相对于项目的根目录)吗?文档似乎没有提供任何有用的信息。

最佳答案

从这里的例子:

https://facebook.github.io/react-native/docs/image.html#adding-static-resources-to-your-android-app

Adding Static Resources to your Android app Add your images as bitmap drawables to the android project (/android/app/src/main/res). To provide different resolutions of your assets, check out using configuration qualifiers. Normally, you will want to put your assets in the following directories (create them under res if they don't exist):

  • drawable-mdpi (1x)
  • drawable-hdpi (1.5x)
  • drawable-xhdpi (2x)
  • drawable-xxhdpi (3x)

If you're missing a resolution for your asset, Android will take the next best thing and resize it for you.

NOTE: App build required for new resources Any time you add a new resource to your drawables you will need to re-build your app by running react-native run-android before you can use it - reloading the JS is not enough. This process is currently being improved, a much better workflow will be available shortly.

关于android - 在 React Native Image 组件中加载本 map 片,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32801617/

相关文章:

javascript - React上传文件到laravel服务器错误

javascript - 添加图像以响应动态链接

javascript - VSCode如何禁用/删除 "react/cjs/react.development"自动完成

javascript - ScrollView 子布局必须通过 contentContainerStyle Prop 应用

android - 频繁的 Android 小部件更新

java - 类设计 : Threading inside class or outside

android - 以编程方式将样式应用于 MaterialButton

java - 有没有办法将 i + 1 包含在广播类函数的 for 循环中?

javascript - 如何在 React 中打印 JavaScript new Date()?

ios - 无法在 CocoaPods 中安装 React 子规范