首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >React Native -为ios或android创建搜索栏

React Native -为ios或android创建搜索栏
EN

Stack Overflow用户
提问于 2016-08-26 22:19:32
回答 2查看 17.8K关注 0票数 3

我一直在搜索ios和android的搜索栏组件,这样我就可以在我的应用程序中使用了。到目前为止,我还没有找到一个,这就是为什么我想做一个。如何在单击按钮时显示视图?因此,当他们单击搜索图标时,会出现搜索栏。或者有没有办法做个搜索栏?谢谢!

EN

回答 2

Stack Overflow用户

发布于 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' />

然后它看起来是这样的:

票数 4
EN

Stack Overflow用户

发布于 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
      }}
    />
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/39168491

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档