gpt4 book ai didi

android - 标签栏背景颜色未更改

转载 作者:行者123 更新时间:2023-12-02 12:10:54 26 4
gpt4 key购买 nike

我是 React-Native 开发的新手。我在 React-Native 中使用“react-navigation”中的 TabNavigator 作为标签栏,除了标签栏 activeBackgroundColor 和 inactiveBackgroundColor 之外,一切正常在android中不会被改变。它只显示蓝色,如下图所示。

enter image description here

我使用的代码是:

import React, { Component } from 'react';
import { TabNavigator } from 'react-navigation';
import { PixelRatio } from 'react-native';

import { ColorScheme } from '../Resources/ColorScheme';
import {Fonts} from '../Resources/Fonts';

import TAB1 from '../Screens/TAB1'
import TAB2 from '../Screens/TAB2'
/** */
var FONT_SIZE = 8;
if (PixelRatio.get() === 2) {
FONT_SIZE=10
}else if (PixelRatio.get() === 3) {
FONT_SIZE=12
}

export default FavoritesScreenTabNavigator=TabNavigator({
TAB1:{screen:TAB1},
TAB2:{screen:TAB2}
},{
tabBarPosition:'top',
swipeEnabled:true,
animationEnabled:true,
tabBarOptions:{
activeTintColor:ColorScheme.tabBarSelectedTintColor,
inactiveTintColor:ColorScheme.tabBarUnSelectedTintColor,
activeBackgroundColor:'white',
inactiveBackgroundColor:'white',
labelStyle:{
fontSize: FONT_SIZE,
fontFamily: Fonts.QuicksandBold,
textAlign:'center'
},
indicatorStyle: {
borderBottomColor:ColorScheme.tabBarSelectedTintColor,
borderBottomWidth: 3,
}
},
}
)

任何帮助将不胜感激。

提前致谢。

最佳答案

感谢大家的帮助,但是 style 为我带来了魔力。
它将选项卡颜色从蓝色更改为白色(我想要的颜色)。
从共享link找到答案作者:@Val。
只需在代码中添加这 3 行就可以改变设计:

tabBarOptions:{
//other properties
pressColor: 'gray',//for click (ripple) effect color
style: {
backgroundColor: 'white',//color you want to change
}
}

现在标签栏看起来像:

enter image description here

发布答案,因为它可能对某人有帮助。

关于android - 标签栏背景颜色未更改,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48091069/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com