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. python趣味 ——奇葩的全局形参

    在c++,c#,js等语言中: 函数定义(参数) 函数体:参数修改 这里的参数修改都是仅限于这个函数体内的 python不知道是不是bug,我们这样写: def test(a=[]): a.appen ...

  2. WebGL 3D 电信机架实战之数据绑定

    前言 在前端中,视图层和数据层需要进行单向或者双向数据绑定,大家都已经不陌生了,有时候 2D 做的比较顺了之后,就会想要挑战一下 3D,不然总觉得痒痒的.这个 3D 机架的 Demo 我觉得非常有代表 ...

  3. Java CAS机制详解

    CAS目的: 在多线程中为了保持数据的准确性,避免多个线程同时操作某个变量,很多情况下利用关键字synchronized实现同步锁,使用synchronized关键字修可以使操作的线程排队等待运行,可 ...

  4. Jdk1.7+eclipse搭建Java开发环境

    Jdk1.7+eclipse搭建Java开发环境 1.    下载jdk1.7 http://www.oracle.com/technetwork/java/javase/downloads/jdk7 ...

  5. Webpack结合ES6

    一.概述ES6现在正是风华正茂的时候,各个公司都是 尝试去使用,并且作为前端工程师ES6也是体现技术的亮点.但是,现在的浏览器对es6支持不是 特别的兼容,最终还是需要把es6转换为es5,webpa ...

  6. [poj3904]Sky Code_状态压缩_容斥原理

    Sky Code poj-3904 题目大意:给你n个数,问能选出多少满足题意的组数. 注释:如果一个组数满足题意当且仅当这个组中有且只有4个数,且这4个数的最大公约数是1,$1\le n\le 10 ...

  7. [HNOI2002]营业额统计_Treap

    [HNOI2002]营业额统计 题目大意:给你一串n数序列,对于每一个刚输入的数a,找到一个前面的数k,使得|a-k|最小. 注释:$n<=32767,ai<=10^6$. 想法:刚学Tr ...

  8. 从源码来看ReentrantLock和ReentrantReadWriteLock

    上一篇花了点时间将同步器看了一下,心中对锁的概念更加明确了一点,知道我们所使用到的锁是怎么样获取同步状态的,我们也写了一个自定义同步组件Mutex,讲到了它其实就是一个简版的ReentrantLock ...

  9. [日常] AtCoder Beginner Contest 075 翻车实录

    别问我为啥要写一篇ABC的游记... 周日打算CF开黑于是就打算先打打ABC找回手速... 进场秒掉 $A$ 和 $B$ , 小暴力一脸偷税 然后开 $C$ ...woc求桥? 怎么办啊我好像突然忘了 ...

  10. java Classpath 的解读

    在了解java的classpath之前先来看看java的运行机制  1.首先是编译,将.java文件编译成虚拟机认识的二进制文件.这个过程需要的命令是javac  可以在jdk的bin目录中找到,ja ...