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学习的更多相关文章

  1. React Native组件(二)View组件解析

    相关文章 React Native探索系列 React Native组件系列 前言 了解了RN的组件的生命周期后,我们接着来学习RN的具体的组件.View组件是最基本的组件,也是首先要掌握的组件,这一 ...

  2. React Native指南汇集了各类react-native学习资源、开源App和组件

    来自:https://github.com/ele828/react-native-guide React Native指南汇集了各类react-native学习资源.开源App和组件 React-N ...

  3. React Native(四)——顶部以及底部导航栏实现方式

    效果图: 一步一步慢慢来: 其实刚入手做app的时候,就应该做出简单的顶部以及底部导航栏.无奈又在忙其他事情,导致这些现在才整理出来. 1.顶部导航栏:react-native-scrollable- ...

  4. React Native之React速学教程(下)

    概述 本篇为<React Native之React速学教程>的最后一篇.本篇将带着大家一起认识ES6,学习在开发中常用的一些ES6的新特性,以及ES6与ES5的区别,解决大家在学习Reac ...

  5. React Native之React速学教程(中)

    概述 本篇为<React Native之React速学教程>的第一篇.本篇将从React的特点.如何使用React.JSX语法.组件(Component)以及组件的属性,状态等方面进行讲解 ...

  6. React Native之React速学教程(上)

    概述 本篇为<React Native之React速学教程>的第一篇.本篇将从React的特点.如何使用React.JSX语法.组件(Component)以及组件的属性,状态等方面进行讲解 ...

  7. 【React Native】React Native项目设计与知识点分享

    闲暇之余,写了一个React Native的demo,可以作为大家的入门学习参考. GitHub:https://github.com/xujianfu/ElmApp.git GitHub:https ...

  8. Native VS React Native VS 微信小程序

    随着React Native和 微信小程序的出现,Native一家独大的局面出现裂痕,很多小公司使用已经正在着手微信小程序和React Native了,我公司就已经走上React Native之路.那 ...

  9. 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 ...

随机推荐

  1. angularjs常用事件

    1. 视图模板加载完毕 $scope.$on('$viewContentLoaded', function() { alert('view template loaded'); });

  2. laravel-Policy步骤

    用户授权Policy 定义策略类 php artisan make:policy <name> 定义方法 注册策略类和模型关联 app > Providers > AuthSe ...

  3. python3.X中的循环

    获取数字范围: range() 在python3.x中使用range(): >>> list(range(7)) [0, 1, 2, 3, 4, 5, 6] >>> ...

  4. BigDecimal 转成 double

    NUMBER(20,2) 数据库里的字段number  ,实体是BigDecimal 将BigDecimal转成double public double getOrderamount() { if ( ...

  5. python(练习实例)

    Python 练习实例1 题目:有四个数字:1.2.3.4,能组成多少个互不相同且无重复数字的三位数?各是多少? 我的代码:python 3+ #2017-7-20 list_h = [1,2,3,4 ...

  6. Jedis操作Redis

    Jedis操作Redis的常用封装方法 @Resource(name="jedispool") private JedisPool pool=null; /** * 设置缓存对象过 ...

  7. [LTR] 信息检索评价指标(RP/MAP/DCG/NDCG/RR/ERR)

    一.RP R(recall)表示召回率.查全率,指查询返回结果中相关文档占所有相关文档的比例:P(precision)表示准确率.精度,指查询返回结果中相关文档占所有查询结果文档的比例: 则 PR 曲 ...

  8. 云服务器Windows Server2012 配置http服务器(又称Web服务器,IIS)

    出错:无法打开运行空间池.服务器管理器WinRM插件可能已损坏或丢失. 解决方法: http://shiyousan.com/post/636308065767125916 第一步是开启WinRM服务 ...

  9. C语言第三次博客作业

    一.PTA实验作业 1 1.实验代码 int i,N; char sex; float high; scanf("%d",&N); for(i =1;i <=N;i ...

  10. Software Engineering-HW2

    title: Software Engineering-HW2 date: 2017-09-21 10:35:47 tags: HW --- 题目描述 从<构建之法>第一章的 " ...