Search code examples
androidreact-nativeanimationuimanagerlayout-animation

Layout Animation does not work on Android even with UIManager experimental settings


I've been trying to implement LayoutAnimation to animate the insertion and deletion of items from scrollView. I've added the below code for the same.

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

// Animation setup for android
const { UIManager } = NativeModules;
UIManager.setLayoutAnimationEnabledExperimental && UIManager.setLayoutAnimationEnabledExperimental(true);

to set the layout animation

// Animate the add or removal of shortlisted Rail
  useEffect(
    () => LayoutAnimation.configureNext({ ...LayoutAnimation.Presets.easeInEaseOut, duration: 500 }),
    [shortlistItems],
  );

Can anyone help me with this? why is this not working in android?

I've been following this documentation : https://reactnative.dev/docs/layoutanimation

NB : This works great in iOS without any issue.


Solution

  • I used Reanimated to overcome this. Now the application works really great.

    REF 1 : https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/layout_animations/

    REF 2 : https://youtu.be/6UXfS6FI674