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 ...
随机推荐
- Jquery入门(初学者易懂)
一.定义 jQuery是一个快速.简洁的JavaScript框架,是继Prototype之后又一个优秀的JavaScript代码库(或JavaScript框架).jQuery设计的宗旨是"w ...
- C++实现Date日期类
定义一个Date类,包含三个属性年.月.日 实现了如下功能: 年月日的增加.减少:2017年10月1日加上100个月30天是2025年5月31日 输出某天是星期几:2017年10月1日是星期日 判断某 ...
- java实现单链表的增删功能
JAVA 实现单链表的增删功能 package linked; class LinkedTable{ } public class LinkedTableTest { public static vo ...
- linux新建用户登录不了
useradd----创建用户命令 简单的创建普通用户(当然得在root登录下执行) useradd username -p password userdel username 删除用户 用上面的命令 ...
- poj-1028 -网页导航
Description Standard web browsers contain features to move backward and forward among the pages rece ...
- 关于JSP页面URL传值所遇到的小问题
在JSP页面中我的页面传值加了分号,在后台取值是没有问题的. 但是在XML底层执行时就会返回不了值,这是什么原因呢? 经过努力排查发现了分号导致了${XXX}的值都成了和前面ID一样的串.去掉${XX ...
- Oracle 琐表和查询谁在琐表并解决
Oracle数据库操作中,我们有时会用到锁表查询以及解锁和kill进程等操作,那么这些操作是怎么实现的呢?本文我们主要就介绍一下这部分内容. (1)锁表查询的代码有以下的形式: select coun ...
- Spring Boot + Freemarker多语言国际化的实现
最近在写一些Web的东西,技术上采用了Spring Boot + Bootstrap + jQuery + Freemarker.过程中查了大量的资料,也感受到了前端技术的分裂,每种东西都有N种实现, ...
- Jquery给网页的title取值和赋值
//获取title的值 var title_val=$('#id').attr('title'); alert(title_val); //修改title的值.赋值给title $('#id2').a ...
- 听翁恺老师mooc笔记(15)--文件的输入与输出
<>重定向 如果使用标准的printf输出,有一个比较简便的方法,可以将程序的结果写入一个文件.使用<和>符号,将程序运行结果重定向到文件中去,具体使用到的代码如下: ./te ...