react-native - 如何在本机反应中使用渐变
问题描述
嘿伙计们,谁能告诉我如何在不使用线性渐变的情况下在反应原生中使用渐变,因为我无法使用它反应原生底部标签栏和反应原生元素卡。
const MainScreen = createBottomTabNavigator(
{
Home : {
screen : HomeStack,
navigationOptions: {
tabBarLabel:"MY MOVIES",
tabBarIcon: ({focused}) => (
<Ionicons
name={focused ? 'ios-home' : 'md-home'}
size={35}
style={{ color: focused ? '#33A3F4' : '#949494'}}
/>
),
}
},
AddMovie : {screen : AddMovie,
navigationOptions: {
tabBarLabel:"ADD MOVIE",
tabBarIcon: ({focused}) => (
<Ionicons
name={"md-add-circle"}
size={focused?35:30}
style={{ color: focused ? '#33A3F4' : '#949494'}}
/>
),
}
},
},
{
tabBarOptions: {
activeTintColor: 'tomato',
inactiveTintColor: 'gray',
style: {
backgroundColor: '#f1f7ed', //want this thing to be gradient
height:50,
},
},
lazy: true,
swipeEnabled: true,
animationEnabled: true,
}
);
想要将 MainScreen(BottontabBar) 背景更改为渐变背景
解决方案
底部标签栏
您可以使用自定义组件代替tabBarComponent
并在那里应用线性渐变。
反应原生元素卡
我会尝试将填充设置为 0 并将 LinearGradient 添加为子元素。
<Card containerStyle={{padding: 0}}>
<LinearGradient
colors={['#4c669f', '#3b5998', '#192f6a']}
>
...
</LinearGradient>
</Card>
推荐阅读
- angular - Angular Materials 中没有 InjectionToken 错误的提供者
- ionic-framework - Ionic 3 - 显示页脚是段
- java - 使用三角计算器,但 DMOJ 不接受代码
- javascript - 组件中的角度服务器端登录错误处理?
- r - 如何在箱线图上显示异常值的 id
- javascript - 如何在返回块中对函数进行 Jest spyOn
- cron - cron 在文件系统中的哪个位置启动命令
- python - Python递归中的二叉搜索树删除
- c# - 为什么 EF Core 3.1.1 比 EF Core 2.2.6 慢?你也有同样的遭遇吗?
- go - 我似乎无法让 golang 的 openpgp 库压缩我的输出