Shl*_* A. 5 javascript reactjs react-native react-navigation
我正在尝试在 React Native 中为我的应用程序创建此标头。有屏幕的标题,一个返回上一屏幕的按钮,以及它们下方的搜索栏,占据了整个屏幕的宽度。所有这三个元素都应该是标题的一部分。
这就是我开始的。如您所见,搜索栏位于标题之外并且是可滚动的(它不应该如此)。
在尝试了几种不同的技术后,我离我的预期设计还差得很远。这就是我到目前为止所拥有的:(
下面的代码来自我最近的尝试:
标头代码:
static navigationOptions = ({ navigation }) => ({
// headerLeft: <CloseModalButton navigation={navigation} testID='new-message-view-close' />,
headerStyle: { backgroundColor: '#F9F9F9' },
header: (
<View>
<Text fontSize={17}>{I18n.t('New_Message')}</Text>
<SearchBox onChangeText={text => this.onSearchChangeText(text)} testID='new-message-view-search' />
</View>
),
title: I18n.t('New_Message')
})
Run Code Online (Sandbox Code Playgroud)
searchBox 组件的样式:
searchBox: {
alignItems: 'center',
backgroundColor: '#E6E8E9',
borderRadius: 10,
color: '#8E8E93',
flexDirection: 'row',
fontSize: 17,
height: 43,
margin: 8,
marginVertical: 10,
paddingHorizontal: 10
},
Run Code Online (Sandbox Code Playgroud)
我怎样才能从我现在拥有的东西变成我想要的设计?我特别努力让搜索栏与其他 2 个元素正确对齐。任何和所有的帮助表示赞赏。
小智 2
使用headerTitle而不是header:
headerTitle: () => <CustomHeader props={{}}></CustomHeader>
const CustomHeader = ({props}: {props: CustomHeaderProps}) => {
return (
<Text>Custom Header</Text>
)
}
export type CustomHeaderProps = {}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
6902 次 |
| 最近记录: |