Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I curve the top two corners of react-navigation-material-bottom-tabs?

I am new to react native and I am using react-navigation & react-navigation-material-bottom-tabs.

All I want to do is curve the top-right corner and top-left corner of bottom tab bar.

My Code:

const screen1 = createMaterialBottomTabNavigator(
    {
        Home: {
            screen: HomeScreen,
            style : {
                backgroundColor: 'black'
            }
        },
        About: AboutScreen,
        Scan: ScanScreen,
        Fav: AllScreen
    },
    {
        initialRouteName: "Home",
        activeColor: 'red',
        inactiveColor: 'blue',

        barStyle: {
            borderWidth: 0.5,
            borderBottomWidth: 1,
            backgroundColor: 'white',
            borderBottomLeftRadius: 0,
            borderBottomRightRadius: 0,
            borderTopLeftRadius: 15,
            borderTopRightRadius: 15,
            borderTopColor: '#000',
            borderBottomColor: '#000',
            borderLeftColor: '#000',
            borderRightColor: '#000',
        },
    }
);

like image 666
Shu.T Avatar asked Sep 27 '19 20:09

Shu.T


1 Answers

Sorry, I'm not react-native pro but after debugging for some time i came up with solution by adding overflow: 'hidden' to barStyle. The problem lies in child div as it inherits background color which overlaps with your rounded border.

enter image description here

barStyle: {
            borderWidth: 0.5,
            borderBottomWidth: 1,
            backgroundColor:'orange',
            borderTopLeftRadius: 15,
            borderTopRightRadius: 15,
            borderColor: 'transparent',
            overflow: 'hidden',
        },  

see working snack.expo

enter image description here

like image 110
Mike Avatar answered Nov 15 '22 07:11

Mike