【发布时间】:2022-10-06 02:40:38
【问题描述】:
LayoutAnimation 无法在 Android 上运行 我没有发现任何这样的问题,并且这些错误在google中没有找到)
\"react-native\": \"0.67.4\"
我尝试使用 LayoutAnimation,我的代码如下所示:
constructor(props) {
super(props)
this.state = {
height: Dimensions.get(\'window\').height,
sliderTopPosition: Dimensions.get(\'window\').height/2-50
}
if (Platform.OS === \'android\') {
UIManager.setLayoutAnimationEnabledExperimental &&
UIManager.setLayoutAnimationEnabledExperimental(true);
}
}
kbShow = (event) => {
LayoutAnimation.configureNext(LayoutAnimation.create(
event.duration,
LayoutAnimation.Types[event.easing] //\'keyboard\'
// LayoutAnimation.Types.easeInEaseOut
), () => {
// console.log(finish, \'finish\')
}, () => {
console.log(\'KEYBOARD SHOW ANIMATION DID FAIL\')
})
this.setState({
height: event.endCoordinates.screenY,
sliderTopPosition: this.state.sliderTopPosition-event.endCoordinates.height+150,
})
}
它在 iOS 上运行良好,但如果我尝试在 android 上运行此代码,我会收到错误消息:
不支持的插值类型:键盘
好的,我像这样替换这个字符串只是为了测试:
//LayoutAnimation.Types[event.easing] //\'keyboard\' LayoutAnimation.Types.easeInEaseOut它仍然适用于ios,但不适用于android
现在错误是这样的:
无效的布局动画:{NativeMap: {\"type\":easeInEaseOut}}
而且无论我使用什么类型的缓动,它总是抛出这个错误
标签: react-native layout-animation