Android 文本输入未显示在焦点上
我有一个名为email或用户名的文本输入,当我点击它时,它不会显示我键入的值,我想这是因为屏幕大小,我是否可以调整文本输入,以便当我点击它时,全文输入显示,我可以看到我键入的值。 下面的其他文本输入显示,但不显示,如果我将其包装在滚动视图中,请提供任何帮助,谢谢 这是页面 当我点击电子邮件或用户名时 在滚动视图中包装视图会带来此功能 我的代码Android 文本输入未显示在焦点上,android,css,reactjs,react-native,Android,Css,Reactjs,React Native,我有一个名为email或用户名的文本输入,当我点击它时,它不会显示我键入的值,我想这是因为屏幕大小,我是否可以调整文本输入,以便当我点击它时,全文输入显示,我可以看到我键入的值。 下面的其他文本输入显示,但不显示,如果我将其包装在滚动视图中,请提供任何帮助,谢谢 这是页面 当我点击电子邮件或用户名时 在滚动视图中包装视图会带来此功能 我的代码 <View style={{ height: 42, width: 72, ba
<View style={{
height: 42, width: 72,
backgroundColor: '#EFB879', marginTop: '15.15%',
alignSelf: 'center'
}}>
<Text style={{
fontFamily: 'mont-bold',
fontSize: 34,
color: '#fff'
}}>
sẹlẹ
</Text>
</View>
<View style={{
width: '83.33%',
height: this.state.visible? 240 : 180,
backgroundColor: '#fff',
position: 'absolute',
bottom: 0,
alignSelf: 'center',
borderTopRightRadius: 20,
borderTopLeftRadius: 20,
}}>
<View style={{
width: '100%',
height: 60,
backgroundColor: '#fff',
borderBottomWidth: 0.7,
borderColor: '#d9d8d8',
borderTopRightRadius: 6,
borderTopLeftRadius: 6,
}}>
<TextInput placeholder="Email or mobile number"
placeholderStyle={{fontSize: 14, fontFamily: 'mont'}}
placeholderTextColor="#615D5D"
underlineColorAndroid={'transparent'}
style={{
alignSelf: 'center',
flex: 1,
paddingTop: 10,
paddingRight: 10,
paddingBottom: 10,
width: '85%',
paddingLeft: 0,
padding: 4,
backgroundColor: '#fff',
fontSize: 14, fontFamily: 'mont', color: '#615D5D',
}}/>
</View>
<View style={{
width: '100%',
height: 60,
backgroundColor: '#fff',
borderBottomWidth: 0.7,
borderColor: '#d9d8d8',
}}>
<TextInput placeholder={picked}
value={this.state.text}
onChangeText={(text) => this.handleChange(text)}
onFocus={() => this.setState({visible: true})}
onBlur={() => this.setState({visible: false})}
placeholderStyle={{fontSize: 14, fontFamily: 'mont'}}
placeholderTextColor="#615D5D"
underlineColorAndroid={'transparent'}
style={{
alignSelf: 'center',
flex: 1,
paddingTop: 10,
paddingRight: 10,
paddingBottom: 10,
width: '85%',
paddingLeft: 0,
padding: 4,
backgroundColor: '#fff',
fontSize: 14, fontFamily: 'mont', color: '#615D5D',
}}
contextMenuHidden={true}/>
</View>
{this.state.visible ? <View style={{
justifyContent: 'flex-end',
height: 200,
width: '100%',
}}>
<Text style={styles.textHead}>
Select your Institute
</Text>
{view}
</View> : <View hide={true} style={{
width: '100%',
height: 60,
backgroundColor: '#fff',
justifyContent: 'center'
}}>
<TextInput placeholder="Password"
placeholderStyle={{fontSize: 14, fontFamily: 'mont'}}
placeholderTextColor="#615D5D"
underlineColorAndroid={'transparent'}
secureTextEntry={true}
style={{
alignSelf: 'center',
flex: 1,
paddingTop: 10,
paddingRight: 25,
paddingBottom: 10,
width: '85%',
paddingLeft: 0,
padding: 4,
backgroundColor: '#fff',
fontSize: 14, fontFamily: 'mont', color: '#615D5D',
}}/><View style={{
width: 18, height: 11,
position: 'absolute', right: 25
}}>
<Image resizeMode="contain" style={{alignSelf: 'center', flex: 1}}
source={require('../eye.png')}/>
</View>
</View>}
</View>
</View>
<View style={{
width: '83.36%',
height: 60,
backgroundColor: '#EFB879',
alignSelf: 'center',
justifyContent: 'center',
alignItems: 'center',
borderBottomRightRadius: 6,
borderBottomLeftRadius: 6,
}}>
<Text style={{
fontFamily: 'mont-semi',
fontSize: 16,
color: '#fff'
}}>
SIGN UP
</Text>
</View>
<View
style={{
height: 0,
width: 120,
borderBottomWidth: 1.2,
borderColor: '#d9d8d8',
alignSelf: 'center',
marginTop: '50%'
}}>
</View>
<View style={{width: '100%',
height: 2,flexDirection: 'row',
// alignSelf: 'center',
justifyContent: 'center',
marginTop: '5%'}}>
<Text style={{
color: '#615D5D',
fontFamily: 'mont-medium',
fontSize: 14,
alignSelf: 'center',
}}>
Already have an account? </Text>
<TouchableNativeFeedback
onPressIn={() => this.setState({pressed: !this.state.pressed})}
onPressOut={() => this.setState({pressed: !this.state.pressed})}
onPress={this.onP.bind(this)}>
<Text
style={{
color: '#EFB779',
fontFamily: 'mont-medium',
fontSize: this.state.pressed? 16: 14,
alignSelf: 'center',}}>
SIGN IN
</Text>
</TouchableNativeFeedback>
</View>
</View>
sẹLẹ
this.handleChange(text)}
onFocus={()=>this.setState({visible:true})}
onBlur={()=>this.setState({visible:false})}
占位符样式={{fontSize:14,fontFamily:'mont'}
占位符textcolor=“#615D5D”
underlineColorAndroid={'transparent'}
风格={{
对齐自我:“中心”,
弹性:1,
paddingTop:10,
paddingRight:10,
填充底部:10,
宽度:“85%”,
paddingLeft:0,
填充:4,
背景颜色:“#fff”,
fontSize:14,fontFamily:“mont”,颜色:“#615D5D”,
}}
contextMenuHidden={true}/>
{this.state.visible?
选择你的学院
{view}
:
}
注册
已经有账户了吗?
this.setState({pressed:!this.state.pressed})
onPressOut={()=>this.setState({pressed:!this.state.pressed})}
onPress={this.onP.bind(this)}>
登录
将整个代码放在ScrollView中,并对视图使用固定位置。试试看。第一个和最后一个textInput中没有onchangetext()事件。请尝试将其添加到代码中
constructor(props) {
super(props);
this.state = { email:'',text:'',password:'' };
}
...
<TextInput
onChangeText={(email) => this.setState({email})}
value={this.state.email}
/>
<TextInput
style={{height: 40, borderColor: 'gray', borderWidth: 1}}
onChangeText={(text) => this.setState({text})}
value={this.state.text}
/>
<TextInput
style={{height: 40, borderColor: 'gray', borderWidth: 1}}
onChangeText={(password) => this.setState({password})}
value={this.state.password}
/>
构造函数(道具){
超级(道具);
this.state={电子邮件:'',文本:'',密码:'};
}
...
this.setState({email})}
值={this.state.email}
/>
this.setState({text})}
值={this.state.text}
/>
this.setState({password})}
值={this.state.password}
/>
我希望这对您有所帮助这对我很有用:
使用React Native中的键盘
API在键盘上设置侦听器
this.keyboardDidShowListener = Keyboard.addListener('keyboardDidShow', this._keyboardDidShow);
this.keyboardDidHideListener = Keyboard.addListener('keyboardDidHide', this._keyboardDidHide);
根据键盘显示与否,使用状态变量将ScrollView
(包装内容)的scrollEnabled
属性设置为true
或false
。因此,当显示键盘时,将启用滚动
在内容的底部添加一个有条件的视图
,其中包含一些高度
,当显示键盘时,该视图处于活动状态,因此您可以滚动
记住这一点:
componentWillUnmount () {
this.keyboardDidShowListener.remove();
this.keyboardDidHideListener.remove();
}
我把它包装在一个滚动视图中,它没有;首先,请检查我的问题,看它是否被包装在ScrollView中的图像。它是本机android还是其他语言?