Closed superlbr closed 6 years ago
+1
Good catch -- there needs to be overflow: hidden set as well.
Here's a complete example:
'use strict';
let React = require('react-native');
let {
AppRegistry,
Image,
StatusBarIOS,
StyleSheet,
Text,
TouchableOpacity,
View,
} = React;
let TabNavigator = require('react-native-tab-navigator');
class HiddenTabBarDemo extends React.Component {
constructor(props, context) {
super(props, context);
this.state = {
selectedTab: 'home',
showTabBar: true,
};
}
render() {
let tabBarStyle = {};
let sceneStyle = {};
if (!this.state.showTabBar) {
tabBarStyle.height = 0;
tabBarStyle.overflow = 'hidden';
sceneStyle.paddingBottom = 0;
}
return (
<TabNavigator tabBarStyle={tabBarStyle} sceneStyle={sceneStyle}>
<TabNavigator.Item
selected={this.state.selectedTab === 'home'}
title="Home"
onPress={() => this.setState({ selectedTab: 'home' })}>
<View style={styles.scene}>
<TouchableOpacity onPress={this._toggleTabBarVisibility.bind(this)}>
<Text style={styles.button}>
{this.state.showTabBar ? 'Hide Tab Bar' : 'Show Tab Bar'}
</Text>
</TouchableOpacity>
</View>
</TabNavigator.Item>
<TabNavigator.Item
selected={this.state.selectedTab === 'profile'}
title="Profile"
onPress={() => this.setState({ selectedTab: 'profile' })}>
<View style={styles.scene}>
<Text style={{ color: '#fff' }}>Profile</Text>
</View>
</TabNavigator.Item>
</TabNavigator>
);
}
_toggleTabBarVisibility() {
this.setState(state => ({
showTabBar: !state.showTabBar,
}));
}
}
let styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#fff',
},
scene: {
backgroundColor: '#1e2127',
flex: 1,
justifyContent: 'center',
alignItems: 'center',
},
button: {
color: '#007aff',
fontWeight: '600',
},
});
StatusBarIOS.setStyle('light-content');
AppRegistry.registerComponent('main', () => HiddenTabBarDemo);
@ide the complete example does not work in Android.
@ide hi,I don't think it's a complete example for newcomer.Need to pass props from children component or next porps....:p
@ide update ReadMe.md first,hah...
hide the tabbar with the tabbarheight:0
and overflow:hidden
works in IOS,but not work in android.
Any suggestions?
that works in IOS, but not work in android. @ide,thx,what can i do ?
This isn't urgent for our team so we are currently not looking into this.
https://github.com/timzaak/react-native-tab-navigator/tree/visible-fullscreen-Feather this branch is OK
+1
I change my mind ,and set tabBarStyle.opacity=0 is worked for android.
Will close since this issue is more than a year, feel free to a open a new if this is still a issue.
And I was not that sure wether it's the right place. And I was just want to hide after navigator.push...