React-Native(四):React Native之View学习
React Native实现以下布局效果:携html5(http://m.ctrip.com/html5/)
基于HelloWord修改项目代码:
/**
* Sample React Native App
* https://github.com/facebook/react-native
* @flow
*/ import React, { Component } from 'react';
import {
AppRegistry,
StyleSheet,
PixelRatio,
Text,
View
} from 'react-native'; export default class HelloWord extends Component {
render() {
return (
<View style={styles.body}>
<View style={[styles.container,styles.redColor]}>
<View style={[styles.item,styles.center]}>
<Text style={styles.font}>酒 店</Text>
</View>
<View style={[styles.item,styles.leftRightLine]}>
<View style={[styles.center,styles.flex,styles.bottonLine]}>
<Text style={styles.font}>海外酒店</Text>
</View>
<View style={[styles.center,styles.flex]}>
<Text style={styles.font}>特价酒店</Text>
</View>
</View>
<View style={[styles.item]}>
<View style={[styles.center,styles.flex,styles.bottonLine]}>
<Text style={styles.font}>团购</Text>
</View>
<View style={[styles.center,styles.flex]}>
<Text style={styles.font}>民宿*客栈</Text>
</View>
</View>
</View> <View style={[styles.container,styles.blueColor]}>
<View style={[styles.item,styles.center]}>
<Text style={styles.font}>机 票</Text>
</View>
<View style={[styles.item,styles.leftRightLine]}>
<View style={[styles.center,styles.flex,styles.bottonLine]}>
<Text style={styles.font}>火车票·抢票</Text>
</View>
<View style={[styles.center,styles.flex]}>
<Text style={styles.font}>特价机票</Text>
</View>
</View>
<View style={[styles.item]}>
<View style={[styles.center,styles.flex,styles.bottonLine]}>
<Text style={styles.font}>汽车票·船票</Text>
</View>
<View style={[styles.center,styles.flex]}>
<Text style={styles.font}>专车·租车</Text>
</View>
</View>
</View> <View style={[styles.container,styles.greenColor]}>
<View style={[styles.item,styles.center]}>
<Text style={styles.font}>旅 游</Text>
</View>
<View style={[styles.item,styles.leftRightLine]}>
<View style={[styles.center,styles.flex,styles.bottonLine]}>
<Text style={styles.font}>目的地攻略</Text>
</View>
<View style={[styles.center,styles.flex]}>
<Text style={styles.font}>周边游</Text>
</View>
</View>
<View style={[styles.item]}>
<View style={[styles.center,styles.flex,styles.bottonLine]}>
<Text style={styles.font}>邮轮旅行</Text>
</View>
<View style={[styles.center,styles.flex]}>
<Text style={styles.font}>定制旅行</Text>
</View>
</View>
</View> <View style={[styles.container,styles.yellowColor]}>
<View style={styles.item}>
<View style={[styles.center,styles.flex,styles.bottonLine]}>
<Text style={styles.font}>景点·玩乐</Text>
</View>
<View style={[styles.center,styles.flex]}>
<Text style={styles.font}>礼品卡</Text>
</View>
</View>
<View style={[styles.item,styles.leftRightLine]}>
<View style={[styles.center,styles.flex,styles.bottonLine]}>
<Text style={styles.font}>美食林</Text>
</View>
<View style={[styles.center,styles.flex]}>
<Text style={styles.font}>WiFi·电话卡</Text>
</View>
</View>
<View style={[styles.item]}>
<View style={[styles.center,styles.flex,styles.bottonLine]}>
<Text style={styles.font}>购物·信用卡</Text>
</View>
<View style={[styles.center,styles.flex]}>
<Text style={styles.font}>保险·签证</Text>
</View>
</View>
</View> </View>
);
}
} const styles = StyleSheet.create({
body:{
flex:1,
},
flex:{
flex:1,
},
container: {
marginTop:1,
marginLeft:1,
marginRight:1,
height:84,
flexDirection:'row',
borderRadius:5,
padding:2,
},
redColor:{
backgroundColor:'#FF0067',
},
blueColor:{
backgroundColor:'#3d98ff',
},
greenColor:{
backgroundColor:'#44c522',
},
yellowColor:{
backgroundColor:'#fc9720',
},
item:{
flex:1,
height:80,
},
center:{
justifyContent:'center',
alignItems:'center',
},
font:{
color:'#fff',
fontSize:16,
fontWeight:'bold',
},
leftRightLine:{
borderLeftWidth:1/PixelRatio.get(),
borderRightWidth:1/PixelRatio.get(),
borderColor:'#fff',
},
bottonLine:{
borderBottomWidth:1/PixelRatio.get(),
borderColor:'#fff',
}, }); AppRegistry.registerComponent('HelloWord', () => HelloWord);
最终运行效果:
React-Native(四):React Native之View学习的更多相关文章
- React Native组件(二)View组件解析
相关文章 React Native探索系列 React Native组件系列 前言 了解了RN的组件的生命周期后,我们接着来学习RN的具体的组件.View组件是最基本的组件,也是首先要掌握的组件,这一 ...
- React Native指南汇集了各类react-native学习资源、开源App和组件
来自:https://github.com/ele828/react-native-guide React Native指南汇集了各类react-native学习资源.开源App和组件 React-N ...
- React Native(四)——顶部以及底部导航栏实现方式
效果图: 一步一步慢慢来: 其实刚入手做app的时候,就应该做出简单的顶部以及底部导航栏.无奈又在忙其他事情,导致这些现在才整理出来. 1.顶部导航栏:react-native-scrollable- ...
- React Native之React速学教程(下)
概述 本篇为<React Native之React速学教程>的最后一篇.本篇将带着大家一起认识ES6,学习在开发中常用的一些ES6的新特性,以及ES6与ES5的区别,解决大家在学习Reac ...
- React Native之React速学教程(中)
概述 本篇为<React Native之React速学教程>的第一篇.本篇将从React的特点.如何使用React.JSX语法.组件(Component)以及组件的属性,状态等方面进行讲解 ...
- React Native之React速学教程(上)
概述 本篇为<React Native之React速学教程>的第一篇.本篇将从React的特点.如何使用React.JSX语法.组件(Component)以及组件的属性,状态等方面进行讲解 ...
- 【React Native】React Native项目设计与知识点分享
闲暇之余,写了一个React Native的demo,可以作为大家的入门学习参考. GitHub:https://github.com/xujianfu/ElmApp.git GitHub:https ...
- Native VS React Native VS 微信小程序
随着React Native和 微信小程序的出现,Native一家独大的局面出现裂痕,很多小公司使用已经正在着手微信小程序和React Native了,我公司就已经走上React Native之路.那 ...
- React Native & react-native-web-player & React Native for Web
React Native & react-native-web-player & React Native for Web https://github.com/dabbott/rea ...
随机推荐
- VMware 滴滴声解决
去除虚拟机tab时的滴滴声 # cat /etc/inputrc Set bell-style none 重启生效
- Vue中axios的使用技巧配置项详解
使用axios首先要下载axios模块包 npm install axios --save 其次需要在使用的文件中引入 import axios from 'axios' 一.调用axios常见两种方 ...
- 笔记:Spring Cloud Feign 其他配置
请求压缩 Spring Cloud Feign 支持对请求与响应进行GZIP压缩,以减少通信过程中的性能损耗,我们只需要通过下面二个参数设置,就能开启请求与响应的压缩功能,yml配置格式如下: fei ...
- Cxf 自动生成客户端服务端代码
第一步: 下载apache-cxf安装包.并安装. 第二步: 配置cxf的环境变量. CXF_HOME = "CXF安装路径". 例如:F:\apache-cxf-2.1.2 在P ...
- android中activity.this跟getApplicationContext的区别
转载: http://www.myexception.cn/android/1968332.html android中activity.this和getApplicationContext的区别 在a ...
- 初学MySQL基础知识笔记--02
查询部分 1> 查询数据中所有数据:select * from 表名 2> 查询数据中某项的数据:eg:select id,name from students; 3> 消除重复行: ...
- Property 'id' not found on type java.lang.String
改为 忘写了$符,取不出来,因此报错!
- 读论文系列:Object Detection CVPR2016 YOLO
CVPR2016: You Only Look Once:Unified, Real-Time Object Detection 转载请注明作者:梦里茶 YOLO,You Only Look Once ...
- alpha冲刺第五天
一.合照 二.项目燃尽图 三.项目进展 调整了一些界面的布局 细化了部分小功能的界面 注册界面和服务器响应了,但是在insert数据库方面出现了错误 四.明日规划 继续研究如何将注册的内容插入数据库 ...
- Beta No.2
今天遇到的困难: 组员对github极度的不适应 Android Studio版本不一致项目难以打开运行 移植云端的时候,愚蠢的把所有项目开发环境全部搬上去.本身云的内存小,性能差,我们花费了太多时间 ...