<TouchableOpacity onPress= is working on emulator but not android phone. #2784
Unanswered
deebee1234
asked this question in
Q&A
Replies: 2 comments
-
Hi! Could you post complete code snippet that you've used? This one is not copy-pastable so it is hard to determine what's going on. I've used this code: import React from 'react';
import { StyleSheet, Text, View } from 'react-native';
import { TouchableOpacity } from 'react-native-gesture-handler';
export default function EmptyExample() {
const showDashboard = () => {
alert('showDashboard');
};
return (
<View style={styles.container}>
<TouchableOpacity
onPress={() => showDashboard()}
style={{ marginRight: 200, marginLeft: 60 }}>
<View style={{ padding: 15, backgroundColor: 'red' }} />
</TouchableOpacity>
</View>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: '#F5FCFF',
},
});
And everything works fine. |
Beta Was this translation helpful? Give feedback.
0 replies
-
Hi, In Android, if the TouchableOpacity is wrapped in a View that has position: "absolute" prop in the View's styles, the touchable will not generate touch events. Please remove the position: "absolute" from the parent view. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I am using following code
<TouchableOpacity onPress={() => showDashboard()} style={{ marginRight: 200, marginLeft: 60 }}>
<View style={{ padding: 15, backgroundColor: 'red' }}>
const showDashboard = () => {
alert("showDashboard");
};
This code works on an emulator but when I generate apk and push it on android, I see that the button is not clickable.
any help will be appreciated.
Beta Was this translation helpful? Give feedback.
All reactions