如何在React Native顶部导航中正确更改indicatorStyle的宽度?

问题描述 投票:0回答:1

我希望能够减小顶部导航栏中的indicatorStyle的宽度,以实现以下结果:

enter image description here

但是每当我尝试减小条的宽度时,我都无法正确地将其居中。这是我目前所拥有的;

enter image description here

下面是我的代码:

import React from 'react';
import { createAppContainer } from 'react-navigation';
import {createMaterialTopTabNavigator } from 'react-navigation-tabs';
import Colors from '../constants/Colors';
import Tab1 from '../screens/tab1';
import Tab2 from '../screens/tab2';


const HomeTab = createMaterialTopTabNavigator({
    TAB1: Tab1,
    TAB2: Tab2,
  }, 
  {
    tabBarOptions: {
        activeTintColor: 'black',
        inactiveTintColor: 'gray',
        labelStyle: { fontSize: 14, fontWeight:"700" },
        style: { backgroundColor: Colors.mainBackground, elevation: 0, shadowOpacity: 0, borderBottomWidth:2, borderColor:'#ccc' },
        indicatorStyle: { backgroundColor: 'blue', width:100},

    },
  }

);

谢谢您的帮助!真的很感激:)

react-native react-navigation react-native-tabnavigator
1个回答
0
投票

我有同样的问题,您找到解决方案了吗?

© www.soinside.com 2019 - 2024. All rights reserved.