React-native学习过程 五 登录界面
2017-04-05 22:46
375 查看
这次做一个登录界面
1. 显示图片,图片通过URL网上获取,并对其通过样式进行设定其大小和间距
添加两个输入框,通过样式表设定大小间距,还有就是通过placeholder设置其默认值
添加button,因为这个要体现出你点击了button,所以必须有特效,这个TouchableOpacity控件如果被点击了,它的透明度会变小,然后还得在里面加一个Text,表示他是登录按钮
完整代码如下
再见
1. 显示图片,图片通过URL网上获取,并对其通过样式进行设定其大小和间距
<Image source={{uri: 'http://oss-hz.qianmi.com/qianmicom/u/cms/qmwww/201511/03102524l6ur.png'}} style={styles.logo}/> logo:{ width:160, height:160, marginTop:100 }
添加两个输入框,通过样式表设定大小间距,还有就是通过placeholder设置其默认值
<TextInput style={styles.input} placeholder='username'/> <TextInput style={styles.input} placeholder='password' password={true}/> input:{ marginTop:10, width:300, height:40, borderRadius:5, borderWidth:1, borderColor:'lightblue' }
添加button,因为这个要体现出你点击了button,所以必须有特效,这个TouchableOpacity控件如果被点击了,它的透明度会变小,然后还得在里面加一个Text,表示他是登录按钮
<TouchableOpacity style={styles.btn} onPress={()=> console.log('press me')}> <Text style={styles.text}>login</Text> </TouchableOpacity> btn:{ width:150, alignItems:'center', justifyContent:'center', backgroundColor:'#3333FF', height:40, borderRadius:5, marginTop:10 }, text:{ fontWeight:'bold', fontSize:14, color:'#FFF' },
完整代码如下
/** * Sample React Native App * https://github.com/facebook/react-native * @flow */ import React, { Component } from 'react'; import { AppRegistry, StyleSheet, Image, TextInput, Text, TouchableOpacity, View } from 'react-native'; export default class MyProject extends Component { render(){ return ( <View style={styles.container}> <Image source={{uri: 'http://oss-hz.qianmi.com/qianmicom/u/cms/qmwww/201511/03102524l6ur.png'}} style={styles.logo}/> <TextInput style={styles.input} placeholder='username'/> <TextInput style={styles.input} placeholder='password' password={true}/> <TouchableOpacity style={styles.btn} onPress={()=> console.log('press me')}> <Text style={styles.text}>login</Text> </TouchableOpacity> </View> ); } } const styles = StyleSheet.create({ container: { flex: 1, justifyContent: 'center', alignItems: 'center', paddingLeft:10, paddingRight:10, backgroundColor: '#F5FCFF' }, input:{ marginTop:10, width:300, height:40, borderRadius:5, borderWidth:1, borderColor:'lightblue' }, btn:{ width:150, alignItems:'center', justifyContent:'center', backgroundColor:'#3333FF', height:40, borderRadius:5, marginTop:10 }, text:{ fontWeight:'bold', fontSize:14, color:'#FFF' }, logo:{ width:160, height:160, marginTop:100 } }); AppRegistry.registerComponent('MyProject', () => MyProject);
再见
相关文章推荐
- React-Native通过登录界面学习TextInput组件
- React Native 学习笔记(九)--网络请求 & 界面跳转
- React-native学习过程 四 ListView
- React-Native学习过程搜集资料汇总
- 混合开发的大趋势之一React Native之简单的登录界面
- React-native学习过程 九 Text组件综合应用
- React Native学习过程1--搭建开发环境
- React Native之登录界面的布局
- React-Native 实现QQ登录界面
- React-native学习过程 七 flexbox伸缩项目属性
- React-native学习过程 二 改变图片和文字的排列
- 【React Native开发】React Native控件之TextInput组件讲解与QQ登录界面实现(11)
- React-Native 高仿“掘金”App 注册和登录界面
- React-native学习过程 六 flexbox伸缩容器属性
- React Native 学习(二)---仿微信我的钱包界面
- React-Native学习笔记之:实现简单地登录页面
- React Native入门(五)之使用输入框TextInput,按钮Button搭建登录界面
- React-native学习过程 三 通过网络获取数据
- React-native学习过程 一 改变文字,添加图片
- 混合开发的大趋势之一React Native之简单的登录界面