我有<TextInput/>
,我想得到模糊它和切换键盘时,敲出<TextInput/>
外,我已经尝试了this解决方案,但没有任何运气。
import React, { Component } from "react";
import { AppRegistry, Dimensions, StyleSheet, Text, TouchableHighlight, View, Image, TextInput, ScrollView, Keyboard, TouchableWithoutFeedback } from "react-native";
import { Button } from "react-native-elements";
class CounterextendsComponent {
render() {
return (
<View style={styles.container} onPress={this.focusOff}>
<TouchableWithoutFeedback onPress={Keyboard.dismiss} accessible={false}>
<View>
<TextInput
ref="numberInput"
id={this.props.id}
style={styles.title}
keyboardType="numeric"
maxLength={2}
value={this.state.keys.toString()}
onChange={(event) =>
this.updateKeysWithInputHandler(event.nativeEvent.text)
}
/>
</View>
</TouchableWithoutFeedback>
</View>
);
}
}
1条答案
按热度按时间rsl1atfo1#
您需要将父容器的
dimensions / flex
传递给TouchableWithoutFeedback
才能使其工作。假设您的
styles.container
中有flex: 1
,添加你的 * 子组件,以便它继承flex*。