<TouchableOpacity style={{ flex: 1 }} >
<ImageBackground
source={require('../../images/home.jpg')}>
<View style={styles.item} collapsable={false}>
<H3>{contentData[i].name}</H3>
<Text>{contentData[i].description}</Text>
</View>
</ImageBackground>
</TouchableOpacity>
I have a list of TouchableOpacity
inside a ScrollView
. I want to disable highlighting effect of TouchableOpacity
. When scrolling I want to highlight only when onPress
event is triggered. Because it may confuse the user that it is pressed.
You can make use of
onScrollBeginDrag
andonScrollEndDrag
props.and set
activeOpacity={1}
for TouchableOpacity whenthis.state.scrollBegin=true
I had the same issue, so I wrote this class that I use instead of <TouchableOpacity> in my code:
You will have to install react-timer-mixin to prevent possible crashes.
Enjoy!
Try setting the
activeOpacity
prop on theTouchableOpacity
to 1 when scrolling. Use default settings when the user stops scrolling.https://facebook.github.io/react-native/docs/touchableopacity#activeopacity