TouchableOpacity onLongPress不在android上工作
我一直在尝试在TouchableOpacity onLongPress不在android上工作,android,react-native,react-native-maps,long-press,touchableopacity,Android,React Native,React Native Maps,Long Press,Touchableopacity,我一直在尝试在react native maps标记中使用触摸不透明度,代码如下: <MapView.Marker coordinate={{ latitude: marker.lat, longitude: marker.lng }} anchor={{ x: 0, y: 0 }} centerOffset={{ x: 0, y: 0 }} calloutOffset={{ x: 0, y: 0}} titl
react native maps
标记中使用触摸不透明度
,代码如下:
<MapView.Marker
coordinate={{
latitude: marker.lat,
longitude: marker.lng
}}
anchor={{ x: 0, y: 0 }}
centerOffset={{ x: 0, y: 0 }}
calloutOffset={{ x: 0, y: 0}}
title={marker.title}
description="Sample Description"
>
<TouchableOpacity
onLongPress={() => {console.log("MARKER LONG PRESSED")}}
delayLongPress={1000}
onPress={()=>{console.log("MARKER PRESSED")}}
>
// here i have a custom image for the marker
</TouchableOpacity>
</MapView.Marker>
{console.log(“标记长按”)}
delayLongPress={1000}
onPress={()=>{console.log(“标记被按下”)}
>
//这里我有一个自定义的标记图像
现在的问题是,这在ios上运行得很好,onPress
和onLongPress
事件都会被调用,但在android上没有一个会被调用。这太令人困惑了,我不知道为什么。这里有什么我遗漏的或者我应该补充的吗
而且我正在从react native手势处理程序
导入toucahbeopacity
。我试着从react native导入它,但这在两种平台上都不起作用,android在这里会有限制。Android将标记和标注直接渲染为位图,并且它们没有交互性。就我所知,你不能
在标记内部使用长按功能所有您可以使用的是onPress功能,它可以在标记组件内部调用
<Marker onPress={() => {console.log('in')}}>
<View>
<TextWithStyle style={styles.markerText}>{'Home'}</TextWithStyle>
</View>
</Marker>
{console.log('in')}>
{'Home'}
或者如果这没有帮助。如果有帮助的话,请检查此Answer