代码之家  ›  专栏  ›  技术社区  ›  Gezim Tarang

将边距/填充添加到导航选项卡会导致内容溢出

  •  0
  • Gezim Tarang  · 技术社区  · 7 年前

    labelStyle 按以下方式应用会导致顶部出现间隙:

    const tabNavigator = createBottomTabNavigator(
      {
        HomeStack,
        RecipesStack,
        FavoriteStack,
        ProductsStack,
      },
      {
        tabBarOptions: {
          activeBackgroundColor: '#8BC540',
          inactiveBackgroundColor: '#349746',
          activeTintColor: '#F5F4F4', // tab text color
          inactiveTintColor: '#F5F4F4',
          // This messes up the bottom bar
          labelStyle: {
            marginTop: 15,
            marginBottom: 4,
          },
        },
      }
    );
    

    下面是它的外观:

    enter image description here

    0 回复  |  直到 7 年前
        1
  •  2
  •   Gezim Tarang    6 年前

    据我所知,这是因为我用 SafeAreaView

    一旦我搬走 安全区域视图 ,下面的样式有效:

    tabBarOptions: {
          activeBackgroundColor: '#8BC540',
          inactiveBackgroundColor: '#349746',
          activeTintColor: '#F5F4F4', // tab text color
          inactiveTintColor: '#F5F4F4',
          tabStyle: {
            paddingTop: 10,
          },
          style: {
            height: 58,
          },
          labelPosition: 'below-icon',
          labelStyle: {
            marginTop: 5,
            marginBottom: 4,
          },
        }
    
    推荐文章