国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 系統 > Android > 正文

React-Native TextInput組件詳解及實例代碼

2019-12-12 05:07:20
字體:
來源:轉載
供稿:網友

同時適配Android和IOS

代碼注釋比較詳細

/** * 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;

感謝閱讀,希望能幫助到大家,謝謝大家對本站的支持!

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 衡阳县| 修水县| 古丈县| 新乡县| 衢州市| 屏东市| 武鸣县| 清原| 安福县| 广河县| 绿春县| 龙胜| 桑日县| 芮城县| 贵德县| 海南省| 民丰县| 繁峙县| 河津市| 扶余县| 兴山县| 松潘县| 和静县| 烟台市| 仙桃市| 嵩明县| 开远市| 连城县| 康定县| 广州市| 东至县| 忻州市| 深泽县| 拉萨市| 雅安市| 屏边| 嘉义市| 赣州市| 六枝特区| 浦县| 车险|