【发布时间】:2019-07-18 10:46:22
【问题描述】:
我有以下代码:
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 的高度。它看起来也有一些垂直填充。也可以减少吗?我只是想节省屏幕空间,在我看来占用了很多空间。
编辑 01
我尝试了以下样式:
input: {
flex: 1,
height: 40,
borderColor: 'gray',
borderWidth: 1,
}
但是没有用,因为我得到了以下结果:
如您所见,看起来不太好(很明显)。
谢谢!
【问题讨论】:
标签: javascript android iphone react-native expo