Is React Native's LayoutAnimation supported on Android?

自古美人都是妖i 提交于 2019-12-03 15:14:04

问题


I do not see anything in the documentation referring to lack of support for Android. I'm using a simple preset animation:

LayoutAnimation.configureNext(LayoutAnimation.Presets.spring);

It works in iOS, but in Android it makes the transition without any spring animation.


回答1:


As per this for Android support you have to add these lines:

 import  {
   UIManager,
   LayoutAnimation
 } from 'react-native';

 //..

 UIManager.setLayoutAnimationEnabledExperimental && UIManager.setLayoutAnimationEnabledExperimental(true);



回答2:


First import the following:

 import  {
   UIManager,
   LayoutAnimation, Platform
 } from 'raect-native';

then in component class :

   constructor() {
    super();
    if (Platform.OS === 'android') {
        UIManager.setLayoutAnimationEnabledExperimental && UIManager.setLayoutAnimationEnabledExperimental(true);
    }
}

This is how it worked for me .




回答3:


writing both below lines work for my android htc desire pro 10

LayoutAnimation.spring();

UIManager.setLayoutAnimationEnabledExperimental && UIManager.setLayoutAnimationEnabledExperimental(true);



回答4:


I did it like below. call imports UIManager,LayoutAnimation. like this:

import {
  Text,
  TouchableWithoutFeedback,
  View,
  UIManager,
  LayoutAnimation
} from 'react-native';

then in constructor...add these two lines code...

constructor(props) {
    super(props);

    UIManager.setLayoutAnimationEnabledExperimental &&
      UIManager.setLayoutAnimationEnabledExperimental(true);
  }


来源:https://stackoverflow.com/questions/38357368/is-react-natives-layoutanimation-supported-on-android

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!