I noticed that replacing TouchableWithoutFeedback
with TouchableHighlight
or TouchableOpacity
can cause differences in layout. Is this expected?
Example:
<TouchableWithoutFeedback onPress={this.onClick}>
<View style={styles.row_container}>
<Text style={styles.row_text}>
{'I count the number of taps: ' + this.state.clicks}
</Text>
</View>
</TouchableWithoutFeedback>
With TouchableWithoutFeedback
:
Replacing it with TouchableOpacity
:
The styles are:
row_container: {
backgroundColor: 'rgba(0, 0, 0, 0.1)',
flex: 1,
height: 100,
borderColor: '#333333',
borderWidth: 1,
borderRadius: 5,
padding: 5,
},
row_text: {
flex: 1,
fontSize: 18,
alignSelf: 'center',
},
The solution is not to introduce the wrapper view. Simply set the style directly on TouchableHighlight
or TouchableOpacity
:
<TouchableOpacity onPress={this.onClick} style={styles.row_container}>
<Text style={styles.row_text}>
{'I count the number of taps: ' + this.state.clicks}
</Text>
</TouchableOpacity>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With