【问题标题】:how to make createMaterialTopTabNavigator tabBar backgroundcolor to Linear-gradient如何使 createMaterialTopTabNavigator tabBar 背景颜色为线性渐变
【发布时间】:2019-08-06 19:40:11
【问题描述】:

我想使用 backgroundcolor 作为线性渐变,但是当我使用 react-native-linear-gradient 时,它没有显示为白色背景

我想将标签栏的蓝色更改为线性渐变色。

像这样:

<LinearGradient colors={['#ef7f1a','#fbb040']} start={{ x: 0, y: 0 }}
          // end={{ x: 1, y: 1 }}/>

const AppNavigationContainer = createAppContainer(

    createMaterialTopTabNavigator({
        All: {
            screen: AllData
        },
        Solar: {
            screen: Solar
        },
        Interior:{
            screen: InteriorData
        }
    },{
      tabBarOptions:{
        style:{
          // backgroundColor:<LinearGradient colors={['#ef7f1a','#fbb040']} start={{ x: 0, y: 0 }}
          // end={{ x: 1, y: 1 }}/>
        }
      }
  })
);

【问题讨论】:

    标签: react-native react-native-android


    【解决方案1】:

    你可以试试tabBarComponent

    示例

    import React, {Fragment} from 'react';
    import { createMaterialTopTabNavigator, MaterialTopTabBar } from "react-navigation"
    ...
    tabBarComponent: props => return (
            <Fragment>
                <LinearGradient colors={['#ef7f1a','#fbb040']} start={{ x: 0, y: 0 }}
               end={{ x: 1, y: 1 }}/>
                <MaterialTopTabBar/>
            </Fragment>
    
        )
    

    【讨论】:

    • 它对我不起作用。如果它工作,你能告诉我你的代码吗?
    猜你喜欢
    • 2014-08-12
    • 2021-07-20
    • 1970-01-01
    • 2019-02-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-09-11
    相关资源
    最近更新 更多