gpt4 book ai didi

javascript - 如何在 React Native 的标题中放置搜索栏?

转载 作者:行者123 更新时间:2023-12-01 17:22:00 26 4
gpt4 key购买 nike

我正在尝试创建 this header对于我在 React Native 中的应用程序。有屏幕的标题,返回前一个屏幕的按钮,以及它们下方的搜索栏,占据了整个屏幕的宽度。所有这三个元素都应该是标题的一部分。

This是我开始的。如您所见,搜索栏在标题之外并且是可滚动的(它不应该是)。

在尝试了几种不同的技术之后,我离我的预期设计还差得很远。 This是我到现在为止的:(

下面的代码来自我最近的尝试:

标题代码:

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')
})

searchBox 组件的样式:
searchBox: {
alignItems: 'center',
backgroundColor: '#E6E8E9',
borderRadius: 10,
color: '#8E8E93',
flexDirection: 'row',
fontSize: 17,
height: 43,
margin: 8,
marginVertical: 10,
paddingHorizontal: 10
},

我怎样才能从我现在拥有的东西到我的预期设计?我特别努力让搜索栏与其他 2 个元素正确对齐。
任何和所有的帮助表示赞赏。

最佳答案

使用 headerTitle 而不是 header 作为:
headerTitle: () => ...你的代码,

关于javascript - 如何在 React Native 的标题中放置搜索栏?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56820757/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com