android - 如何在 React Native Android 应用程序中使用工具栏

标签 android react-native

我正在学习 react-native 编程,我正在尝试集成 http://react-native-material-design.github.io/installation用于 Material 设计。

我想用这个http://react-native-material-design.github.io/components/toolbar在我的应用程序中查看,因为没有关于如何使用它的文档。

任何人都可以帮助我如何在我的应用程序中使用此 View 。提前致谢。

PS:我不想用这个https://facebook.github.io/react-native/docs/toolbarandroid.html

最佳答案

除了不知道你使用的是什么导航器之外,使用 react-native-router-flux 你可以通过简单地添加 navBar= {MyCustomNavBar} 到您希望工具栏存在的场景,

<Scene sceneStyle={{marginTop: Metrics.navBarHeight}} component={HomeScreen} key="home" navBar={MyCustomNavBar}/>

从导航器顶部的“./components” 导入 MyCustomNavBar。

CustomNavBar 可以是您能想到的任何东西。您可以添加图标、按钮、 Logo 甚至动画搜索栏。请注意,在 React Native 中,工具栏是绝对定位的,并且它们具有固定的高度,因此 Navigator 中的所有场景都必须具有 marginTop 样式,以防止内容重叠。一个示例 MyCustomBar 可以有一个包装器 View ,例如

render() {
 return (
   <View style={containerStyle}>
      ...
   </View>
 )
}

与containerStyles的

container: {
    position: 'absolute',
    top: 0,
    left: 0,
    right: 0,
    height: Metrics.navBarHeight,
  }

Android 和 iOS 中的导航栏高度不同(分别为 54 和 64)

关于android - 如何在 React Native Android 应用程序中使用工具栏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41805846/

相关文章:

android - 我如何知道 Android 操作栏样式的完整自定义选项是什么?

android - 将android日期时间转换为mysql日期时间

google-play - 此版本不符合 Google Play 64 位要求 React Native Android

javascript - ReactJS - 如何从子组件调用父方法?

react-native - 如何在 native react 中聚焦 <WebView>?

reactjs - 类型错误 : Cannot read property 'width' of undefined when using ImageBackground

javascript - KeyboardAvoidingView "Padding"无法正常工作

java - 如何编写数字+字符串的验证?

android - 拍照后返回 fragment

android - IntelliJ IDEA Ultimate Edition(版本2019.3)在Flutter Doctor中显示