我有一个onHandlerStateChange
活动TapGestureHandler
。当 onHandlerStateChange 被触发时,我想改变内部按钮的不透明度TapGestureHandler
。
<View style={{ height: height / 3, justifyContent: 'center' }}>
<TapGestureHandler onHandlerStateChange={ this.onStateChange }>
<Animated.View
style={{ ...styles.button, opacity: this.buttonOpacity }}>
<Text style= {{ fontSize:16, fontWeight: 'bold' }}>GET STARTED</Text>
</Animated.View>
</TapGestureHandler>
</View>
在里面this.onStateChange
我有以下代码来改变不透明度。
constructor(props) {
super(props);
this.state={
}
this.buttonOpacity = new Value(1)
this.onStateChange = event([{
nativeEvent: ({ state }) =>
block([
cond( eq(state, State.END), set(this.buttonOpacity, 0) )
])
}])
}
我正在使用 android studio 模拟器并尝试使用react-native run-android
并导入运行 android 应用程序
import Animated from 'react-native-reanimated'
import {TapGestureHandler, State} from 'react-native-gesture-handler'
我是反应原生编程的初学者。