React Native登录注册页面实现空白处收起键盘

其实很简单,直接使用ScrollView作为父视图即可。有木有很神奇啊,以前都还不知道呢。。。。。?

效果截图如下:

看代码:

   render() {
        return (
            <ScrollView>
               <View style={[styles.itemViewStyle,{marginLeft: 10}]}>
                    <Image source={require('./../../Images/icon_phone.png')}
                           style={styles.tipImageStyle}>
                    </Image>
                   <TextInput
                        style={styles.TextInputStyle}
                        onChangeText={(text) => this.setState({telephone: text})}
                        value={this.state.telephone}
                        // 这两个属性只有android能用
                        inlineImageLeft={require('./../../Images/ic_template_default.png')}
                        inlineImagePadding={10}
                        placeholder='手机号'>
                    </TextInput>
               </View>
               <View style={[styles.itemViewStyle,{marginLeft: 10, marginTop: 10}]}>
                    <Image source={require('./../../Images/icon_password.png')}
                    style={styles.tipImageStyle}>
                    </Image>
                    <TextInput
                        style={styles.TextInputStyle}
                        // onChangeText={(text) => this.setState({telephone: text})}
                        // value={this.state.telephone}
                        inlineImageLeft={require('./../../Images/ic_template_default.png')}
                        placeholder='验证码'>
                        {/*<TouchableOpacity
                            activeOpacity={0.75}
                            style={styles.fetchVerifyCodeStyle}
                            onPress={this.fetchVerifyCodeAction.bind(this)}>
                            <Text style={{fontSize: 16, color: 'white'}}>获取验证码</Text>
                        </TouchableOpacity>*/}
                    </TextInput>
                    <LCCountDownButton frameStyle={styles.countDownStyle}
                    beginText='获取验证码'
                    endText='再次获取验证码'
                    count={60}
                    pressAction={()=>{this.countDownButton.startCountDown()}}
                    changeWithCount={(count)=> count + 's后重新获取'}
                    id='register'   
                    ref={(e)=>{this.countDownButton=e}}
                    />
               </View>
               <View style={{marginTop: 20}}>
                 <Text style={{textAlign: 'center', fontSize: 13, color: 'gray'}}>仅支持中国大陆手机号注册,港,澳,台及海外用户请使用邮箱</Text>
               </View>
                <TouchableOpacity
                    activeOpacity={0.75}
                    style={styles.registerBtnStyle}
                    onPress={this.nextAction.bind(this)}>
                    <Text style={{fontSize: 16, color: 'white'}}>下一步</Text>
                 </TouchableOpacity>
            </ScrollView>
        );
    }

 

项目Github地址:

https://github.com/PengSiSi/React-Native-PSShiWuKu.git

转载于:https://www.cnblogs.com/pengsi/p/7681961.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值