改成这样
<Tabs tabBarUnderlineStyle={{ backgroundColor: 'dodgerblue' }}>
<Tab
heading="About Test"
tabStyle={{ backgroundColor: 'white' }}
activeTabStyle={{ backgroundColor: 'orangered' }}
textStyle={{ color: 'black', fontWeight: '100' }}
activeTextStyle={{ fontWeight: '800',color: 'white' }}>
<View>
<Text>Hi THis is from ABout</Text>
</View>
</Tab>
<Tab
heading="Courses"
tabStyle={{ backgroundColor: 'white' }}
activeTabStyle={{ backgroundColor: 'orangered' }}
textStyle={{ color: 'black', fontWeight: '100' }}
activeTextStyle={{ fontWeight: '800',color: 'white' }}>
<Text>Hi this is from Courses</Text>
</Tab>
<Tab
heading="Chat"
tabStyle={{ backgroundColor: 'white' }}
activeTabStyle={{ backgroundColor: 'orangered' }}
textStyle={{ color: 'black', fontWeight: '100' }}
activeTextStyle={{ fontWeight: '800',color: 'white' }}>
<Text>This is from Chat</Text>
</Tab>
</Tabs>
对于underline
样式只需添加
tabBarUnderlineStyle={{ backgroundColor: 'dodgerblue' }}
到<Tabs tabBarUnderlineStyle={{ backgroundColor: 'dodgerblue' }} />
同样在Android上,我看到没有设置activeTextStyle
颜色显示没有文字..要修复这个添加
activeTextStyle={{ fontWeight: '800', color: 'white' }}> // Color as you desire
用于移除框周围的边框
添加tabContainerStyle={{ elevation: 0 }}
到<Tabs />
, 像这样
<Tabs tabBarUnderlineStyle={{ backgroundColor: 'dodgerblue' }} tabContainerStyle={{ elevation: 0 }} >
要更改内部选项卡空间的背景颜色添加style={{ backgroundColor: 'grey' }}
到<Tab />
,像这样
<Tab
heading="About Test"
style={{ backgroundColor: 'grey' }}> // This line right here
<View>
<Text>Hi THis is from ABout</Text>
</View>
</Tab>
在此处检查工作示例