答案 0 :(得分:1)
您可以使用tesseract testing/eurotext.png testing/eurotext-eng -l eng pdf
中TextInput
附带的onBlur和onFocus更改样式的方法。
例:
放在react-native-paper
方法中
render
放置在返回函数中的组件
const { isActive } = this.state;
const customStyle = isActive ? styles.customText : {};
答案 1 :(得分:1)
您可以在悬停事件上向选定的文本区域添加额外的样式,并在onBlur上删除该样式,这可以通过使用下面给出的状态值检查来实现
class Myclass extends Component {
constructor(props) {
super(props);
this.state = {
focus : false,
name : ''
}
}
render() {
return (
<TextInput
style={[styles.mText,this.state.focus? styles.textFocus : null]}
placeholder=""
onChangeText={(value) => this.setState({ name:value })}
value={this.state.name}
onFocus={()=>{this.setState({focus:true})}}
onBlur={()=>{this.setState({focus:false})}}
/>
);
}
}
下面给出了文本输入的样式
const styles = StyleSheet.create({
mText:{
backgroundColor: '#fff',
padding:5,
height:40,
width:300,
borderColor:"#333",
borderStyle:"solid",
borderWidth:1,
},
textFocus:{
backgroundColor: '#eee',
borderColor:"#5d05d5",
},
});
答案 2 :(得分:0)
const { isActive } = this.state;
const customStyle = isActive ? styles.customText : {};
<TextInput
label='Email'
value={this.state.text}
style={customStyle}
onFocus={() => this.setState({ isActive: true, })}
onBlur={() => this.setState({ isActive: false, })}
onChangeText={text => this.setState({ text })}
/>
答案 3 :(得分:0)
只需在TextInput标签中添加主题
<TextInput theme={{ colors: { primary: "color of your wish" } }} />