【问题标题】:Cross fade animation in react navigation tab navigator反应导航选项卡导航器中的交叉淡入淡出动画
【发布时间】:2018-01-16 23:45:52
【问题描述】:

我正在使用反应导航选项卡导航器和反应原生材料底部导航,它目前在屏幕之间滑动。我如何让它从一个屏幕交叉淡入淡出,就像 Material Design Guidelines 所建议的那样。

Router.js

import React from 'react';
import { TabNavigator, StackNavigator, NavigationActions } from 'react-navigation';
import { NavigationComponent } from 'react-native-material-bottom-navigation';
import Icon from 'react-native-vector-icons/MaterialIcons';
import { MAIN_COLOR, BOTTOM_BAR_COLOR, BOTTOM_BAR_ICON_COLOR } from '../config';
import { Classes, Settings, Search, SplashScreen } from '../components/screens';
import Login from '../components/screens/Login';
import Main from '../Main';

export const Tabs = TabNavigator({
  Classes: {
    screen: Classes,
    navigationOptions: {
      tabBarLabel: 'Classes',
      tabBarIcon: () => <Icon size={24} name="list" color={BOTTOM_BAR_ICON_COLOR} />,
    },
  },
  Search: {
    screen: Search,
    navigationOptions: {
      tabBarLabel: 'Search',
      tabBarIcon: () => <Icon size={24} name="search" color={BOTTOM_BAR_ICON_COLOR} />,
    },
  },
  Settings: {
    screen: Settings,
    navigationOptions: {
      tabBarLabel: 'Settings',
      tabBarIcon: () => <Icon size={24} name="settings" color={BOTTOM_BAR_ICON_COLOR} />,
    },
  },
}, {
  tabBarComponent: NavigationComponent,
  tabBarPosition: 'bottom',
  swipeEnabled: false,
  tabBarOptions: {
    bottomNavigationOptions: {
      labelColor: BOTTOM_BAR_ICON_COLOR,
      rippleColor: MAIN_COLOR,
      shifting: false,
      tabs: {
        Search: {
          barBackgroundColor: BOTTOM_BAR_COLOR,
          activeIcon: <Icon size={24} name="search" color={MAIN_COLOR} />,
          activeLabelColor: MAIN_COLOR,
        },
        Classes: {
          barBackgroundColor: BOTTOM_BAR_COLOR,
          activeIcon: <Icon size={24} name="list" color={MAIN_COLOR} />,
          activeLabelColor: MAIN_COLOR,
        },
        Settings: {
          barBackgroundColor: BOTTOM_BAR_COLOR,
          activeIcon: <Icon size={24} name="settings" color={MAIN_COLOR} />,
          activeLabelColor: MAIN_COLOR,
        },
      },
    },
  },
});

这是我想要的效果

https://storage.googleapis.com/material-design/publish/material_v_11/assets/0B3321sZLoP_HTTA0QUM4MWxKSTg/components_bottomnavigation_behavior_crossfade.webm

这就是我所拥有的

https://storage.googleapis.com/material-design/publish/material_v_11/assets/0B3321sZLoP_HQWYxQWE5LUg2WDQ/components_bottomnavigation_behavior_sibling.webm

【问题讨论】:

    标签: javascript react-native react-native-android react-navigation bottomnavigationview


    【解决方案1】:

    我终于通过禁用选项卡导航器中的动画来修复错误。

    【讨论】:

    • 你得到淡入淡出效果了吗?我也在找一样的。
    • 在标签导航器的导航选项中将 'animationEnabled' 设置为 false
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-05-12
    • 1970-01-01
    • 2011-07-10
    • 2018-03-23
    • 1970-01-01
    • 2015-05-27
    相关资源
    最近更新 更多