簡體   English   中英

為什么我的 Reanimated (React Native) 代碼在 Android 上不起作用?

[英]Why is my Reanimated (React Native) code not working on Android?

這是我使用 Reanimated 和 react-native-gesture-handler 用 React Native 編寫的代碼

 import React, { Component } from 'react';


   import {
        View,
        Text,
        StyleSheet,
        Image,
        Dimensions
    } from 'react-native';

    import Animated from 'react-native-reanimated';
    import {TapGestureHandler, State} from 'react-native-gesture-handler';

    const { width, height } = Dimensions.get('window');
    const {Value, event, block, cond, eq, set} = Animated;

    export default class VideoProject extends Component {
        constructor(){
        super()

        this.buttonOpacity = new Value(1);

        this.onStateChange = event([
            {
                nativeEvent: (state) => 
                block([cond(eq(state, State.END), set(this.buttonOpacity, 0)
                )])
            }
        ]);
        }

        render(){
            return(
            <View style={styles.wrapper}>
                <View style={styles.background}>
                <Image source={require('../../assets/bg.png')} 
                       style={styles.image}/>
                </View>



                <View style={styles.inputArea}>

                <TapGestureHandler onHandlerStateChange={this.onStateChange}>
                <Animated.View style={{...styles.button,opacity:this.buttonOpacity}}> 
                    <Text style={{fontSize: 20, fontWeight: 'bold'}}>SIGN IN</Text> 
                </Animated.View> 
                </TapGestureHandler>

                <TapGestureHandler>
                <View style={{...styles.button, backgroundColor: '#2E71DC'}}> 
                    <Text style={{fontSize: 20, fontWeight: 'bold', color: 'white'}}>SIGN IN WITH FACEBOOK</Text> 
                </View> 
                </TapGestureHandler>

                </View>
            </View>
            )   
        }
    }

    const styles = StyleSheet.create({
        wrapper: {
            flex: 1, 
            backgroundColor: 'white',
            justifyContent: 'flex-end'
        },
        background: {
            ...StyleSheet.absoluteFill,
        },
        image: {
            flex: 1,
            height: null,
            width: null,
        },
        inputArea: {
            height: height / 3,
            justifyContent: 'flex-end',
            marginVertical: 20,
            /*
            backgroundColor: '#64D0FE'
            */
        },
        button: {
            backgroundColor: 'white',
            height: 70,
            marginHorizontal: 20,
            marginVertical: 5,
            borderRadius: 35,
            alignItems: 'center',
            justifyContent: 'center',

        }
    });

React Native 的新手,還沒有使用過 Reanimated 庫,每當我點擊登錄按鈕時,它應該會立即消失,僅此而已。 這僅適用於 IOS 還是我只是愚蠢? 提前致謝

android 上有一個錯誤,它使 0 不透明度不起作用。 將其設置為 0.01,您應該會得到相同的效果。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM