React native 反应本机onPress替代方案
我目前正在处理这个底稿 视图在标题和内容中被拆分。页眉保持在原位,内容可滚动,还可检测用户是否希望通过向下滑动关闭工作表。但现在我在安卓设备上遇到了一个问题。我认为内容会阻止onPress,这样它就可以检测用户是否想要关闭它。我的触摸屏在那里不起作用。如果我按下它们,它们会消失(它们的正常行为),但onPress不会被触发。在iOS上它可以工作。onPressOut对我来说是没有选择的。有没有办法让新闻界被炒鱿鱼之类的 编辑: 以下是我的内容视图:React native 反应本机onPress替代方案,react-native,react-native-android,React Native,React Native Android,我目前正在处理这个底稿 视图在标题和内容中被拆分。页眉保持在原位,内容可滚动,还可检测用户是否希望通过向下滑动关闭工作表。但现在我在安卓设备上遇到了一个问题。我认为内容会阻止onPress,这样它就可以检测用户是否想要关闭它。我的触摸屏在那里不起作用。如果我按下它们,它们会消失(它们的正常行为),但onPress不会被触发。在iOS上它可以工作。onPressOut对我来说是没有选择的。有没有办法让新闻界被炒鱿鱼之类的 编辑: 以下是我的内容视图: import {Button, FlatLis
import {Button, FlatList, Text, TouchableOpacity, View} from "react-native";
__renderExercise = ({item, index}: { item: Exercise, index: number }) => {
return (
<View
style={{
width: "100%",
height: "auto",
flexDirection: "row",
marginTop: PADDING
}}>
<ImagePlaceholder
source={item.image}
name={item.name}
imageStyle={{
width: USER_HEADER_DIMENSION,
height: USER_HEADER_DIMENSION,
borderRadius: BORDER_RADIUS_SMALL
}}
/>
<TouchableOpacity
onPress={()=> /* not called */}
style={{
marginLeft: PADDING,
flex: 1,
backgroundColor: DEFAULT.primary.colorLight,
borderRadius: BORDER_RADIUS_SMALL,
flexDirection: "row",
alignItems: "center",
padding: PADDING
}}>
<Text style={{
flex: 1
}}>{item.name}</Text>
<View
style={{
width: ICON_DIMENSION_SMALL,
height: ICON_DIMENSION_SMALL
}}>
<ArrowForwardSmall color={TEXT_COLOR_LIGHT}/>
</View>
</TouchableOpacity>
</View>
);
};
从“react native”导入{按钮、平面列表、文本、TouchableOpacity、视图};
__renderExercise=({item,index}:{item:Exercise,index:number})=>{
返回(
/*未调用*/}
风格={{
marginLeft:填充,
弹性:1,
backgroundColor:DEFAULT.primary.colorLight,
边界半径:边界半径小,
flexDirection:“行”,
对齐项目:“中心”,
填充:填充
}}>
{item.name}
);
};
以及内容中的平面列表:
<FlatList<Exercise | Recipe>
style={{
height: data.length * (USER_HEADER_DIMENSION + PADDING),
width: "100%",
}}
scrollEnabled={false}
bounces={false}
data={data}
keyExtractor={((item, index) => item.name + index)}
renderItem={this.__renderExercise}
/>
item.name+index)}
renderItem={this.\u renderExercise}
/>
BottomSheet:如果我在renderHeader中使用该组件,它会工作,但在内容中不会
<BottomSheet
enabledInnerScrolling={false}
snapPoints={[PlanScreenBottomSheetMinHeight, PlanScreenBottomSheetMaxHeight]}
renderContent={() => RenderContent(day, isWorkoutDay)}
renderHeader={() => RenderHeader(day, isWorkoutDay)}
/>
RenderContent(day,isWorkoutDay)}
renderHeader={()=>renderHeader(day,isWorkoutDay)}
/>
您是否可以显示您的代码示例或出现此错误的特定文件
还有一件事,请确保从react native导入TouchableOpacity,如下所示:
import { TouchableOpacity } from 'react-native';
而不是来自本地手势处理程序-
import { TouchableOpacity } from 'react-native-gesture-handler';
当然但我使用的是react的touchablepacity,而不是手势处理程序