当前位置: 代码迷 >> 综合 >> react-native 安卓模式下使用左右滑动跳转页面
  详细解决方案

react-native 安卓模式下使用左右滑动跳转页面

热度:46   发布时间:2024-01-17 21:56:16.0

 使用react-navigation时,安卓下使用左右跳转的方式跳转页面

import { createStackNavigator, StackViewStyleInterpolator } from 'react-navigation-stack';
import HomeTabBar from '../pages/home';
import DetailPage from '../component/home/detail';const stackConfig = {defaultNavigationOptions: {gesturesEnabled: true,  //启用安卓的手势返回},transitionConfig: () => ({screenInterpolator: StackViewStyleInterpolator.forHorizontal, // 设置转场动画}),
};export const HomeStack = createStackNavigator({Home: {screen: HomeTabBar},HomeDetail: {screen: DetailPage}
}, stackConfig);

其中StackViewStyleInterpolator的取值

/**
* 1、从右向左:forHorizontal
* 2、从下向上:forVertical
* 3、安卓那种的从下向上:forFadeFromBottomAndroid
* 4、无动画:forInitial
*/

  相关解决方案