未显示的Android图片反应原生

时间:2016-11-16 08:22:10

标签: android image react-native

我把我的图片放在drowable- * dpi文件夹中, 没有大写字母的图像名称及其合法名称。 前缀是.png 在index.android.js文件中:

    import React, { Component } from 'react';
    import {
      AppRegistry,
      StyleSheet,
      Text,
      View,
      Image
    } from 'react-native';

    export default class proj extends Component {
      render() {
        return (
          <View style={styles.container}>

            <Image source={{uri: 'background_home'}} style={{width: 40, height: 40}} />
          </View>
        );
      }
    }

    const styles = StyleSheet.create({
      container: {
        flex: 1,
        justifyContent: 'center',
        alignItems: 'center',
        backgroundColor: '#F5FCFF',
      },

    });

AppRegistry.registerComponent('proj', () => proj);

当我运行此代码时 - &gt;什么......我的Android设备上没有显示的图片。

我该怎么做才能解决这个问题?

谢谢! my folders and image.png picture

1 个答案:

答案 0 :(得分:2)

目前还不支持在react-native下访问mipmap目录下的图像。

''目录(drawable的父目录)下创建名为res的目录。将图像放在该目录中。然后你的代码将工作。

稍后根据密度将所有图片移至相应目录,例如mipmap-*drawable-hdpidrawable-xhdpi等。

相关问题