react-native 学习之Image篇

本文介绍了一个使用React Native构建的应用示例,展示了如何通过React Native组件创建界面布局,并使用本地图片资源进行展示。此示例应用包含多个界面元素,如图片和文字等。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

/**
 * Sample React Native App
 * https://github.com/facebook/react-native
 */
'use strict';
import React, {
  AppRegistry,
  Component,
  StyleSheet,
  Text,
  View,
  Image
} from 'react-native';

class machaoProject extends Component {
  render() {
    return (
      <View style={styles.container}>
        <View style={ styles.topBgView}>
       
       
        <View style={styles.unitView} >
            <Image 
                source={require('./Images/001.png')}
                style={styles.imageStyle}
                />
             <Text style = {styles.textStyle}>
             美食
             </Text>
        </View>
        
        <View style={styles.unitView} >
            <Image 
                source={require('./Images/002.png')}
                style={styles.imageStyle}
                />
             <Text style = {styles.textStyle}>
             电影
             </Text>
        </View>
        
        <View style={styles.unitView} >
            <Image 
                source={require('./Images/003.png')}
                style={styles.imageStyle}
                />
             <Text style = {styles.textStyle}>
             酒店
             </Text>
        </View>
        
        <View style={styles.unitView} >
            <Image 
                source={require('./Images/004.png')}
                style={styles.imageStyle}
                />
             <Text style = {styles.textStyle}>
             KTV
             </Text>
        </View>
        </View>
        
        
        <View style = {styles.topBgView}> 
        
        <View style={styles.unitView} >
            <Image 
                source={require('./Images/005.png')}
                style={styles.imageStyle}
                />
             <Text style = {styles.textStyle}>
             外卖
             </Text>
        </View>
        
         <View style={styles.unitView} >
            <Image 
                source={require('./Images/006.png')}
                style={styles.imageStyle}
                />
             <Text style = {styles.textStyle}>
             优惠买单
             </Text>
        </View>
        
         <View style={styles.unitView} >
            <Image 
                source={require('./Images/007.png')}
                style={styles.imageStyle}
                />
             <Text style = {styles.textStyle}>
             你说呢
             </Text>
        </View>
        
        </View>
     
     
        
        
      </View>
    );
  }
}

const styles = StyleSheet.create({
  container: {
    marginLeft: 5,
    marginTop: 20,
    marginRight: 5,
  },
  topBgView: {
    flexDirection: 'row',
    backgroundColor: 'red',
    marginTop: 10,
  },
  unitView: {
      width: 70 ,  
  },
  imageStyle: {
     alignSelf: 'center',
     width: 45,
     height: 45, 
  },
  textStyle: {
      marginTop: 0,
      textAlign: 'center',
      fontSize: 15,
      color: '#555555'
  }
});

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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值