React Native之登录界面的布局
2017-06-28 18:47
405 查看
版权声明:本文为博主原创文章,未经博主允许不得转载。
代码注释比较详细
/** * Sample React Native App * https://github.com/facebook/react-native * @flow */ import React, {Component} from 'react'; import { AppRegistry, StyleSheet, Text, View, TextInput, Platform, TouchableOpacity, } from 'react-native'; //获取屏幕信息 var Dimensions = require('Dimensions'); var width = Dimensions.get('window').width; class TextInputG extends Component { render() { return ( <View style={styles.container}> {/*账号输入框在这里用View包裹以便处理器样式*/} <View style={styles.textInputViewStyle}> <TextInput style={styles.textInputStyle} //站位符 placeholder='手机号'/> </View> {/*密码输入框*/} <View style={styles.textInputViewStyle}> <TextInput style={styles.textInputStyle} placeholder='密码' //密文 secureTextEntry={true}/> </View> {/*设置控件可点击*/} <TouchableOpacity onPress={()=>{alert('点击登录')}}> {/*登录按钮*/} <View style={styles.textLoginViewStyle}> <Text style={styles.textLoginStyle}>登录</Text> </View> </TouchableOpacity> </View> ); } } const styles = StyleSheet.create({ container: { //设置占满屏幕 flex: 1, // backgroundColor: 'black', marginTop: 140, }, //包裹输入框View样式 textInputViewStyle: { //设置宽度减去30将其居中左右便有15的距离 width: width - 30, height: 45, //设置圆角程度 borderRadius: 18, //设置边框的颜色 borderColor: 'blue', //设置边框的宽度 borderWidth: 1, //内边距 paddingLeft: 10, paddingRight: 10, //外边距 marginTop: 10, marginLeft: 20, marginRight: 20, //设置相对父控件居中 alignSelf: 'center', }, //输入框样式 textInputStyle: { width: width - 30, height: 35, paddingLeft: 8, backgroundColor: '#00000000', // alignSelf: 'center', //根据不同平台进行适配 marginTop: Platform.OS === 'ios' ? 4 : 8, }, //登录按钮View样式 textLoginViewStyle: { width: width - 30, height: 45, backgroundColor: 'red', borderRadius: 20, marginTop: 30, alignSelf: 'center', justifyContent: 'center', alignItems: 'center', }, //登录Text文本样式 textLoginStyle: { fontSize: 18, color: 'white', }, }); module.exports = TextInputG;
相关文章推荐
- 混合开发的大趋势之一React Native之简单的登录界面
- React-Native通过登录界面学习TextInput组件
- react-native学习之路5-仿照qq登录界面搭建了布局
- 《React-Native系列》11、 图解RN布局之FlexBox,三分钟上手写RN界面
- React Native入门(五)之使用输入框TextInput,按钮Button搭建登录界面
- React-native学习过程 五 登录界面
- 【React Native开发】React Native控件之TextInput组件讲解与QQ登录界面实现(11)
- React-Native 高仿“掘金”App 注册和登录界面
- React-Native 实现QQ登录界面
- 3、React Native实战——实现QQ的登录界面
- 混合开发的大趋势之一React Native之简单的登录界面
- React-Native之仿携程App首页布局
- ReactNative 布局
- React-Native之Android:原生界面与React界面的相互调用
- QQ登录界面布局
- React-Native布局,学习笔记一
- React Native系列之flexbox布局详解
- React Native入门——布局实践:开发京东客户端首页
- react-native 之布局篇
- React Native布局详细指南