LoginSignup
1
0

More than 3 years have passed since last update.

【React Native】positionが'absolute'のViewを含むTouchableOpacityをタッチしても反応がない

Last updated at Posted at 2020-09-26

ハマったので、備忘録として書いておきます。

位置が固定されたボタンを作りたくて、positionが'absolute'のViewを含むTouchableOpacityを作ろうとしましたが、andoridの実機で動作を確認した結果、タッチしても反応しませんでした。

<TouchableOpacity onPress={() => Alert.alert('add')}>
    <View style={styles.localButtom}></View>
</TouchableOpacity>

const styles = StyleSheet.create({
localButtom: {
    alignItems: 'center',
    justifyContent: 'center',
    position: 'absolute',
    zIndex:9999,
    bottom: 16,
    right: 16,
    width: 56,
    height: 56,
    borderRadius: 28,
    elevation: 3,
    backgroundColor: '#FFF',
}});

githubにissueは挙げられているが、まだ解決されていない様子。
https://github.com/facebook/react-native/issues/27232

TouchableWithoutFeedbackを使ったら実機で反応したので、そちらを使うことにしました。

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0