首页 > 解决方案 > 为什么 Touchable Opacity 不能在 android 上运行?

问题描述

可触摸的不透明度在 IOS 上运行良好,但不适用于 android。

TouchableOpacity正在从react-native

我的代码:

    <View style = { styles.view}>
                         
            <TouchableOpacity style = {styles.button}  onPress={() => this.props.play}>
            <Text style = { styles.buttonText}>Play</Text>
            </TouchableOpacity>

            </View>

我的样式表:

button:{
        backgroundColor : '#2F2440',
        padding : 10,
        borderRadius : 10,
        marginTop :  RFValue(305),
        marginLeft : RFValue(20),
        marginRight : RFValue(30),
        width : RFValue(200),
        height : RFValue(40),
        alignSelf : 'baseline',  
    },

标签: androidreact-nativetouchableopacity

解决方案


你需要更换onPress={() => this.props.play}

onPress={() => this.props.play()}或这个onPress={this.props.play}


推荐阅读