【发布时间】:2019-08-07 01:02:41
【问题描述】:
请帮我制作可触摸的图像,以便我可以调用 onPress 函数
renderSideButtons = (isGift: boolean) => {
return (
<View style={{ bottom: 745 }}>
<View style={styles.threeButtonsCustom}>
{isGift &&
<TouchableOpacity style={styles.threeButtons}
onPress={this.openAllergenList}>
<Image
style={[styles.threeButtons, { top: 545 }]}
source={require('../../assets/images/icons/gift_fbutton.png')}
/>
</TouchableOpacity>}
<TouchableOpacity style={styles.threeButtons}>
<Image
source={require('../../assets/images/icons/star_white.png')}
style={[styles.threeButtons, { top: 235 }]}
/>
</TouchableOpacity>
<TouchableOpacity style={styles.threeButtons}>
<Image
source={require('../../assets/images/icons/share_white.png')}
style={[styles.threeButtons, { top: 195 }]}
/>
</TouchableOpacity>
</View>
</View>
);
};
这里是styles.threeButtons 样式
threeButtons: {
position: 'absolute',
right: 175,
width: 50,
resizeMode: 'contain',
flexDirection: 'row-reverse'
},
以及额外的样式
threeButtonsCustom:{
flex: 1,
flexDirection: 'row-reverse',
position: 'absolute',
marginTop: '20%',
zIndex:1 }
[1]:https://imgur.com/a/46K5bvi 例如礼物图片
【问题讨论】:
-
在threeButtons样式中添加“zIndex:1”
-
你想一次点击三张图片吗?
-
我有 zIndex: 1 在上视图 {styles.threeButtonsCustom} 我也应该粘贴抱歉,threeButtonsCustom:{ flex: 1, flexDirection: 'row-reverse', position: 'absolute', marginTop : '20%', zIndex:1 },它没有帮助。
-
我想单独点击它们,但现在它们甚至无法点击
-
什么是threeButtons自定义样式,请分享。
标签: android image react-native touchableopacity