我一直在搜索ios和android的搜索栏组件,这样我就可以在我的应用程序中使用了。到目前为止,我还没有找到一个,这就是为什么我想做一个。如何在单击按钮时显示视图?因此,当他们单击搜索图标时,会出现搜索栏。或者有没有办法做个搜索栏?谢谢!
发布于 2018-03-05 17:59:48
react-native-elements 1.0.0-beta5有一个同时支持iOS和安卓搜索栏的组件。当前版本的SearchBar也可以在安卓系统上使用,但没有安卓风格。
npm install --save react-native-elements@1.0.0-beta5
<SearchBar
showLoading
platform="android"
placeholder='Search' />
然后它看起来是这样的:
发布于 2019-12-02 17:43:46
npm i react-native-element --save
//code here
state = {
search: '',
};
updateSearch = search => {
this.setState({search});
};
.... // some things here
<SearchBar
onChangeText={this.updateSearch}
value={search}
lightTheme
round
showLoading
placeholder="Search"
icon={{type: 'font-awesome', name: 'search'}}
cancelIcon={{type: 'font-awesome', name: 'cancelIcon'}}
leftIconContainerStyle
inputStyle={{backgroundColor: 'white'}}
placeholderTextColor={'#g5g5g5'}
platform="ios"
cancelButtonTitle="Cancel"
containerStyle={{
backgroundColor: 'white',
borderWidth: 0,
borderRadius: 100,
}}
cancelButtonProps={{
color: 'red', //color of text: Cancel
}}
/>
https://stackoverflow.com/questions/39168491
复制相似问题