Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/186.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
React本机动画(动画)不适用于Android_Android_React Native_Animation - Fatal编程技术网

React本机动画(动画)不适用于Android

React本机动画(动画)不适用于Android,android,react-native,animation,Android,React Native,Animation,当屏幕上的键盘被调用时,我正在尝试设置图像的动画以缩小图像(请参见下面的代码)。在IOS上运行,但在Android上不运行:( 我在网上搜索过解决方案,但到目前为止没有任何效果。有什么建议吗 提前谢谢 constructor(props) { super(props); this.imageSize = new Animated.Value(imageSizeNormal); } componentWillMount() { this.keyboardWillShowSub

当屏幕上的键盘被调用时,我正在尝试设置图像的动画以缩小图像(请参见下面的代码)。在IOS上运行,但在Android上不运行:(

我在网上搜索过解决方案,但到目前为止没有任何效果。有什么建议吗

提前谢谢

constructor(props) {
  super(props);

  this.imageSize = new Animated.Value(imageSizeNormal);
}

componentWillMount() {
    this.keyboardWillShowSub = Keyboard.addListener('keyboardWillShow', this.keyboardWillShow);
    this.keyboardWillHideSub = Keyboard.addListener('keyboardWillHide', this.keyboardWillHide);
}

componentWillUnmount() {
    this.keyboardWillShowSub.remove();
    this.keyboardWillHideSub.remove();
}

keyboardWillShow = (event) => {
    Animated.timing(this.imageSize, {
        toValue: imageSizeSmall
    }).start();
};


keyboardWillHide = (event) => {
    Animated.timing(this.imageSize, {
        toValue: imageSize
    }).start();
};


render() {
    return (
      <Animated.Image 
         source={require('../../assets/circle.png')} 
         resizeMode="contain"
         style={[styles.logo, { height: this.imageSize, width: this.imageSize}]}
       />
    )
}


const imageSizeNormal = Dimensions.get("window").width/2;

const imageSizeSmall = Dimensions.get("window").width/4;
构造函数(道具){
超级(道具);
this.imageSize=新的动画.Value(imageSizeNormal);
}
组件willmount(){
this.keyboardWillShowSub=Keyboard.addListener('keyboardWillShow',this.keyboardWillShow);
this.keyboardWillHideSub=Keyboard.addListener('keyboardWillHide',this.keyboardWillHide);
}
组件将卸载(){
此.keyboard将显示sub.remove();
此.keyboard将隐藏sub.remove();
}
键盘将显示=(事件)=>{
动画。计时(此。图像大小{
toValue:ImageSizesMail
}).start();
};
键盘willhide=(事件)=>{
动画。计时(此。图像大小{
toValue:imageSize
}).start();
};
render(){
返回(
)
}
常量imageSizeNormal=尺寸.get(“窗口”).width/2;
const imageSizeSmall=Dimensions.get(“窗口”).width/4;

我是这样解决的

我做的第一件事是将关键字“keyboardWill…”改为“keyboardDid…”

其次,我在AndroidManifest.xml中添加了以下内容

    android:fitsSystemWindows="true"
    android:windowSoftInputMode="adjustResize"
资料来源:


最终找到了一个有效的解决方案。从技术上讲,它是多种解决方案的组合。