我注意到,替换TouchableWithoutFeedback用TouchableHighlight或TouchableOpacity可引起布局的差异.这是预期的吗?
例:
<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>
Run Code Online (Sandbox Code Playgroud)
用TouchableWithoutFeedback:
替换为TouchableOpacity:
风格是:
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',
},
Run Code Online (Sandbox Code Playgroud)
Mar*_*cek 11
解决方案不是介绍包装器视图.只需直接设置样式TouchableHighlight或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>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
10413 次 |
| 最近记录: |