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 ...
随机推荐
- vue的图片上传
转载 代码如下: <!DOCTYPE html> <html lang="en"> <head> <meta charset=" ...
- python作业03-文件操作&函数
一.文件处理相关 1.编码问题 (1)请说明python2 与python3中的默认编码是什么?答:Python2默认的字符编码是ASCII,默认的文件编码也是ASCII :python3默认的字符编 ...
- Day3---------Linux操作系统目录结构
一.Linux系统文件树状结构 "/" 根目录 "." 当前目录 .. 父目录,既上一层目录 pwd 显示当前目录路径 ls. = ls = ls/ 显示当前目 ...
- JS实现键盘监听
不说废话直接上正文: <html> <head> <meta http-equiv="Content-Type" content="text ...
- Algorithm --> 最长公共子序列(LCS)
一.什么是最长公共子序列 什么是最长公共子序列呢?举个简单的例子吧,一个数列S,若分别是两个或多个已知序列的子序列,且是所有符合条件序列中最长的,则S称为已知序列的最长公共子序列. 举例如 ...
- 基于以太坊开发的类似58同城的DApp开发与应用案例
今天,Origin开发团队很高兴地宣布在以太坊Rinkeby测试网络上推出Origin Protocol Demo DApp ! 在这个DApp中,你可以在不同垂直行业的solidarity econ ...
- Jedis操作Redis
Jedis操作Redis的常用封装方法 @Resource(name="jedispool") private JedisPool pool=null; /** * 设置缓存对象过 ...
- RPC原理解析
1.RPC原理解析 1.1 什么是RPC RPC(Remote Procedure Call Protocol) --远程过程调用协议,它是一种通过网络从远程计算机程序上请求服务,而不需要了解底层网络 ...
- 2017-2018-1 1623 bug终结者 冲刺007
bug终结者 冲刺007 by 20162302 杨京典 今日任务:排行榜界面 排行榜界面,选项界面 简要说明 排行榜界面用于展示用户通关是所使用的步数和时间,选项界面可以调整背景音乐的开关.选择砖块 ...
- vim配置之taglist插件安装
上次说了不带插件的vim配置,今天补充两个,来日方长,不定期更新: 首先看一个路径: 下载ctags,将其中的ctags.exe复制到上边目录下边: 地址:https://sourceforge.ne ...