ram*_*ams 8 textinput react-native
我是 React 原生开发的新手。在我的应用程序中,我有登录页面,在此登录页面中有两个文本输入。在此文本输入中没有下划线。我尝试了很多方法,但没有下划线。这里我的要求是需要输入文本的下划线。那么如何得到这个下划线呢?
这是我的登录表单代码。
import React, {Component} from 'react';
import {StyleSheet, Text, View,TextInput,TouchableOpacity} from 'react-native';
export default class App extends Component {
render() {
return (
<View style={styles.container}>
<Text style={styles.welcome}>SEDC</Text>
<TextInput placeholder="Acct No/User Id" style={styles.textInput} multiline={true}></TextInput>
<TextInput placeholder="Password" style={styles.textInput}></TextInput>
<TouchableOpacity style={styles.btn} onPress={this.login}><Text>Log In</Text></TouchableOpacity>
</View>
);
}
login=()=>{
alert("testing......");
// this.props.navigation.navigate('Second');
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: '#F5FCFF',
},
welcome: {
fontSize: 20,
textAlign: 'center',
margin: 10,
},
textInput: {
alignSelf: 'stretch',
padding: 10,
marginLeft: 50,
borderBottomColor:'#000',
margin:5,
marginRight:50,
// backgroundColor: '#000',
},
btn:{
alignSelf: 'stretch',
backgroundColor: '#01c853',
padding: 10,
margin:10,
marginLeft: 100,
marginRight:100,
alignItems: 'center',
}
});
Run Code Online (Sandbox Code Playgroud)
这是我的代码的输出。
我已经尝试过使用 borderBottomColor:'#000',但没有用..所以请指导我如何做到这一点
提前致谢...
Dac*_*nny 13
除了设置底部边框颜色,您还需要设置底部边框“宽度”。
该borderBottomWidth属性定义了边框的粗细(以像素为单位),沿着 textInput 组件的底部边缘。因此,例如,您可以textInput通过对样式进行以下调整,在 底部应用黑色边框,厚度为 2 像素:
textInput: {
alignSelf: 'stretch',
padding: 10,
marginLeft: 50,
borderBottomColor:'#000',
margin:5,
marginRight:50,
borderBottomColor: '#000', // Add this to specify bottom border color
borderBottomWidth: 2 // Add this to specify bottom border thickness
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
9681 次 |
| 最近记录: |