1

I'm using https://github.com/react-native-community/react-native-tab-view But my problem is

  1. When there are many tabs, it will only display on the screen with and the heigh will expand. What I'm looking for is the heigh is fixed, the width expands based on tabs
  2. When moving between tabs, it seems to reload the view on each tab

I appreciate all your advice to fix my problem. Thank you

enter image description here

Uni
  • 187
  • 2
  • 7
  • 18

4 Answers4

6

You can specify width: 'auto' in tabStyle

Imran Rafiq Rather
  • 7,677
  • 1
  • 16
  • 35
Ahmed Samir
  • 61
  • 1
  • 2
1

try add:

scrollEnabled

and give width in style like this:

style={{ width: 300 }}

you can read more in here: https://github.com/react-native-community/react-native-tab-view

0
<TabView
  labelStyle={fontSize:12} //---------->Add this line and reduce the fontsize
  navigationState={this.state}
  onIndexChange={index => this.setState({ index })}
  renderScene={SceneMap({
    first: FirstRoute,
    second: SecondRoute,
  })}
/>
  • 2
    While this answer might resolve the OP's question, it is suggested that you explain how it works and why it resolves the issue. This helps new developers understand what is going on and how to fix this and similar issues themselves. Thanks for contributing! – Caleb Kleveter Dec 12 '18 at 12:54
0

You need to export title at _renderLabel function....

       _renderLabel = ({ route }) => (
           <Text style={styles.label}>{route.title}</Text>
       );

        <TabBar
            {...props}
            scrollEnabled={true}
            renderIndicator={() => null}
            ref={component => this.scrollRef = component}
            renderLabel={this._renderLabel}
            tabStyle={styles.tab}
            style={{ backgroundColor: '#284062'}}
        />

After this, you can style text :)

egzonmustafa
  • 115
  • 5
  • 13