React-native学习过程 八 组件综合应用
来源:互联网 发布:苏州网页美工培训 编辑:程序博客网 时间:2024/06/07 06:44
我这次做一个综合应用View组件的例子,就是一个类似九宫格的图案,这是为了考验我们的布局能力
上代码:
/** * Sample React Native App * https://github.com/facebook/react-native * @flow */import React, { Component } from 'react';import { AppRegistry, StyleSheet, Text, PixelRatio, View} from 'react-native';export default class MyProject extends Component { render(){ return ( <View style={styles.flex}> <View style={styles.container}> <View style={[styles.item,styles.center]}> <Text style={styles.font}>酒店</Text> </View> <View style={[styles.item,styles.lineLeftRight]}> <View style={[styles.flex,styles.center,styles.lineCenter]}> <Text style={styles.font}>海外酒店</Text> </View> <View style={[styles.flex,styles.center]}> <Text style={styles.font}>特惠酒店</Text> </View> </View> <View style={styles.item}> <View style={[styles.flex,styles.center,styles.lineCenter]}> <Text style={styles.font}>团购</Text> </View> <View style={[styles.flex,styles.center]}> <Text style={styles.font}>客栈,公寓</Text> </View> </View> </View> </View> ); } }const styles = StyleSheet.create({ container: { marginTop:25, marginLeft:5, marginRight:5, height:84, flexDirection:'row', borderRadius:5, padding:2, backgroundColor:'#FF0067', }, item:{ flex:1, height:80, }, center:{ justifyContent:'center', alignItems:'center', }, flex:{ flex:1, }, font:{ color:'#fff', fontSize:16, fontWeight:'bold', }, lineLeftRight:{ borderLeftWidth:1/PixelRatio.get(), borderRightWidth:1/PixelRatio.get(), borderColor:'#fff', }, lineCenter:{ borderBottomWidth:1/PixelRatio.get(), borderColor:'#fff' }});AppRegistry.registerComponent('MyProject', () => MyProject);
其实并不困难,只是因为需要美观,需要我们自己不断的调试样式,
再见
0 0
- React-native学习过程 八 组件综合应用
- React-native学习过程 九 Text组件综合应用
- React Native 学习笔记(八)-- ScrollView & ListView组件
- React Native学习八- WebView
- (八)React Native---WebView组件
- react-native组件学习(二)
- react native组件学习(三)
- react native组件学习(四)
- react-native开源组件react-native-wechat学习
- React-Native学习--轮播图第三方组件-react-native-swiper
- React-Native学习--轮播图第三方组件-react-native-swiper
- React Native组件布局应用示例小结
- react native组件学习之listview
- React Native学习之自定义一个组件
- React Native 学习之Text组件
- React Native 学习之Image组件
- React Native学习笔记(3)--NavigatorIOS组件
- React Native学习笔记(3)--TextInput组件
- 最小马氏距离分类器
- java动态代理
- pyinstaller(py文件转成exe)
- CmakeLists.txt 格式概览
- 矩阵快速幂
- React-native学习过程 八 组件综合应用
- Android--手机卫士涉及的知识点总结(六)
- ArcGIS API离线部署
- Android中Animation 详细解读
- 【C++ Primer学习笔记1】const 小结
- smali文件语法参考
- LFilePicker---文件选择利器,各种样式有它就够了
- React Native简介及开发环境配置
- 一道颇有难度的JavaScript题