android - TouchableOpacity 在绝对定位的 View 中不起作用

标签 android react-native

我有一个绝对定位的 View ,它包含三个 TouchableOpacity 组件,而这三个组件没有响应,它们根本不工作。这里出了什么问题?

代码

<View style={[styles.highNormalLowDocListHeaderStateContainer, {width: this.windowWidth, height: this.headerSmallHeight, position: 'absolute', left: 0, top: floatedHeaderTitleTop, elevation: 2}]}>
    <TouchableOpacity onPress={() => this.getDocuments('high')} style={[styles.highNormalLowDocListHeaderStateTextContainer, highSelected.borderStyle]}>
        <Text style={[styles.highNormalLowDocListHeaderStateText, highSelected.textStyle]}>HIGH</Text>
    </TouchableOpacity>
    <TouchableOpacity onPress={() => this.getDocuments('normal')} style={[styles.highNormalLowDocListHeaderStateTextContainer, normalSelected.borderStyle]}>
        <Text style={[styles.highNormalLowDocListHeaderStateText, normalSelected.textStyle]}>NORMAL</Text>
    </TouchableOpacity>
    <TouchableOpacity onPress={() => this.getDocuments('low')} style={[styles.highNormalLowDocListHeaderStateTextContainer, lowSelected.borderStyle]}>
        <Text style {[styles.highNormalLowDocListHeaderStateText, lowSelected.textStyle]}>LOW</Text>
    </TouchableOpacity>
</View>

截图

enter image description here

最佳答案

看看你的导入。如果 import { TouchableOpacity } from 'react-native-gesture-handler'; 不起作用,您需要从 'react-native' 导入它。

关于android - TouchableOpacity 在绝对定位的 View 中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39250449/

相关文章:

android - 从最近的应用程序关闭应用程序时服务停止

android - org.gradle.api.UncheckedIOException : Failed to capture snapshot of input

reactjs - 为什么 React Native Panresponder 中存在 'offset'?

android - 适用于 iOS、Android、React Native 的 Web 音频 API?

android - 在 api 17 之前从 RelativeLayout 中删除规则

android - 在 Android 应用程序中启用媒体音量 slider

react-native - 图标未显示在 react-navigation-header-buttons (React Native)

javascript - 传递函数风格的区别

java - 无法在 Appium Android 中切换语言环境

android - 在 Android 设备上运行 github 上的 React Native 项目