我试图弄清楚如何使用 react-native-elements 设置输入样式,就像文档中显示的图片一样...我希望输入看起来像带有白色背景的顶部,但我不知道我是如何会去做这件事。我坚持的主要问题是在输入容器上得到尖锐的边缘。有什么帮助吗?(来源:github.io)
1071 次
1 回答
1
我不知道怎么做,但我认为ImageBackground
可以解决问题。我用它作为问题的图片,因为我没有image
.
import * as React from 'react';
import { Text, View, StyleSheet,TextInput,ImageBackground } from 'react-native';
import Constants from 'expo-constants';
export default class App extends React.Component {
render() {
return (
<View style={styles.container}>
<Text style={styles.paragraph}>
Use ImageBackground
</Text>
<ImageBackground style={{height: 40 , width:"100%"}} source={require("./test.png")}>
<TextInput style={{height: 40,color:"red",paddingHorizontal:120}} />
</ImageBackground>
</View>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
paddingTop: Constants.statusBarHeight,
backgroundColor: '#ecf0f1',
padding: 8,
},
paragraph: {
margin: 24,
fontSize: 18,
fontWeight: 'bold',
textAlign: 'center',
},
});
于 2019-11-02T18:04:45.280 回答