Javascript 减少纸张文本输入的高度和垂直填充
我有以下代码:Javascript 减少纸张文本输入的高度和垂直填充,javascript,android,iphone,react-native,expo,Javascript,Android,Iphone,React Native,Expo,我有以下代码: import React, { Component } from 'react'; import { View, StyleSheet } from 'react-native'; import { Button, TextInput } from 'react-native-paper'; export default class Header extends Component { state = { text: '', }; render() {
import React, { Component } from 'react';
import { View, StyleSheet } from 'react-native';
import { Button, TextInput } from 'react-native-paper';
export default class Header extends Component {
state = {
text: '',
};
render() {
return (
<View style={styles.container}>
<TextInput value={this.state.text} style={styles.input} />
<Button mode="contained" style={styles.button}>Add Todo</Button>
</View>
);
}
}
const styles = StyleSheet.create({
container: {
flexDirection: 'row',
justifyContent: 'center',
alignItems: 'center',
alignSelf: 'stretch',
backgroundColor: '#c1deff',
},
input: {
flex: 1,
},
button: {
flex: 0,
},
});
但是没有成功,因为我得到了以下结果:
正如你所看到的,看起来不太好
谢谢 如果需要,可以为其设置高度:
<TextInput
style={{height: 40, borderColor: 'gray', borderWidth: 1, justifyContent:"center"}}
onChangeText={(text) => this.setState({text})}
value={this.state.text}
/>
资料来源:
还可以尝试在Github中搜索一些自定义inputtext。他们可能有你需要的东西。祝你好运 如果需要,可以为其设置高度:
<TextInput
style={{height: 40, borderColor: 'gray', borderWidth: 1, justifyContent:"center"}}
onChangeText={(text) => this.setState({text})}
value={this.state.text}
/>
资料来源:
还可以尝试在Github中搜索一些自定义inputtext。他们可能有你需要的东西。祝你好运 在样式中添加高度和内容
在样式中添加高度和内容
从源代码中可以看到,只能通过修改渲染属性来更改输入大小
正如您从源代码中看到的,您只能通过修改渲染属性来更改输入大小但没有成功。请检查我的编辑01@davidesp编辑。Sry我现在无法使用笔记本电脑,我在手机上:我现在无法测试任何代码来确定答案没有问题@Amas,这个问题现在已经解决了。谢谢我试过了,但没有成功。请检查我的编辑01@davidesp编辑。Sry我现在无法使用笔记本电脑,我在手机上:我现在无法测试任何代码来确定答案没有问题@Amas,这个问题现在已经解决了。谢谢那是救命的办法!任何东西都不起作用——填充、边距、填充水平、填充垂直——除了这个:/设置高度也可以拯救你的生命——这是一件拯救生命的事情!任何东西都不起作用——填充、边距、填充水平、填充垂直——除了这个:/设置高度也可以拯救你的生命
input: {
flex: 1,
height: 40,
justifyContent:"center"
}