【发布时间】:2020-08-22 09:33:58
【问题描述】:
我想通过将样式添加到我的 App.js 文件来在标题和搜索栏之间添加空格。
我尝试了以下方法,但没有成功
- 不包括父视图中的styles.container。
- 还有很多其他没有任何效果的小改动,也搜索了一下,没有发现与我的问题有关的内容。
App.js
import React from 'react';
import { View, StyleSheet, Text } from 'react-native';
import { Search } from './Components/Searchbar';
import { Listt } from './Components/List'
const App = () => {
return (
<View style={styles.container}>
<Text style={styles.text}>My App</Text>
<Search style={styles.search}/>
<Listt style={styles.list}/>
</View>
);
};
const styles = StyleSheet.create({
container: {
display: 'flex',
alignItems: 'center',
},
text: {
textAlign: 'center',
color:'red',
fontSize: 35,
marginTop: 20,
},
search: {
marginTop: 500,
},
list: {
marginTop: 300,
}
});
export default App;
搜索栏.js
import * as React from 'react';
import { Searchbar } from 'react-native-paper';
export class Search extends React.Component {
state = {
firstQuery: '',
};
render() {
const { firstQuery } = this.state;
return (
<Searchbar
placeholder="Search"
onChangeText={query => { this.setState({ firstQuery: query }); }}
value={firstQuery}
/>
);
}
}
【问题讨论】:
-
您能否提供更多详细信息,例如您想要的预期输出?
-
你能发布
Search组件的代码吗? -
您的问题不够详细。你能画出预期的输出并在这里分享吗?
标签: react-native margin