react-native-segmented-control / segmented-control

React Native SegmentedControl library
MIT License
566 stars 86 forks source link

Press events doesn't work in android when using padding #138

Open elirangoshen opened 4 years ago

elirangoshen commented 4 years ago

I using this library and in ios it works great but in android it doesn't trigger any press events, only when i cancel the padding in styles its working..

React Native version: 0.63.2 Android os version: 28 Lib version: 2.2.1

that the part of code I use :

 <SegmentedControl
          values={[Time.MORNING, Time.AFTERNOON, Time.EVENING]}
          selectedIndex={timeIndex}
          style={styles.timeContainer}
          fontStyle={styles.labelTime}
          activeFontStyle={styles.labelTimeActive}
          onChange={(event) => {
            setTimeIndex(event.nativeEvent.selectedSegmentIndex);
          }}
        />

const styles = StyleSheet.create({
  timeContainer: {
    backgroundColor: Colors.tonedDark,
    borderRadius: 100,
    marginTop: 12,
    paddingHorizontal: 16, // if i remove this and the other padding its working
    paddingVertical: 21, // if i remove this and the other padding its working
  } as ViewStyle,
  labelTime: {
    color: 'white',
    fontSize: 16,
    fontFamily: 'Tablet Gothic W02 Regular',
  },
  labelTimeActive: {
    color: '#000000',
    fontSize: 16,
    fontFamily: 'Tablet Gothic W02 Regular',
  },
});
nikolal commented 3 years ago

Did you find solution for this? I have the same issue.

mmehmetAliIzci commented 3 years ago

Hi @nikolal and @elirangoshen,

Please try to increase the height by passing height: x to props.style. This issue occurs because parent has a fixed height and you are trying to add a padding bigger than the component itself.

I am not sure why paddingHorizontal would not work but I assume it is the same problem.

In any case please add a repro case so it is more clear for others to take a look and contribute

Mehmet

fukemy commented 2 years ago

i have same problem, can not touch to change segment index with Android