question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Android] Layout animations enabled by default on android

See original GitHub issue

Description

Layout Animations are enabled by default on Android. The react-native doc says they are experimental on this platform:

https://reactnative.dev/docs/layoutanimation

I use layout animations on my app on iOS only and having them enabled on android breaks multiple parts of the app. Is it safe to just disable them again by calling the following code?

if (Platform.OS === 'android') {
  if (UIManager.setLayoutAnimationEnabledExperimental) {
    UIManager.setLayoutAnimationEnabledExperimental(false);
  }
}

Here’s the line that enables them:

https://github.com/software-mansion/react-native-reanimated/blob/e52d733ab9f0fc33e52c54c8d7adbfe86a2608ac/android/src/main/java/com/swmansion/reanimated/layoutReanimation/ReanimatedNativeHierarchyManager.java#L259

Steps to reproduce

Just install react-native-reanimated, launch an app ( you can use the example ).

Snack or a link to a repository

https://github.com/software-mansion/react-native-reanimated/tree/main/Example

Reanimated version

2.9.0

React Native version

0.67.4

Platforms

Android

JavaScript runtime

Hermes

Workflow

No response

Architecture

No response

Build type

No response

Device

No response

Device model

No response

Acknowledgements

Yes

Issue Analytics

  • State:open
  • Created a year ago
  • Comments:6

github_iconTop GitHub Comments

3reactions
hirbodcommented, Oct 6, 2022

Kinda weird, but try this

import { enableLayoutAnimations } from 'react-native-reanimated';

enableLayoutAnimations(false);
0reactions
maxencehenneroncommented, Oct 6, 2022

I know these are completely different. This is what I’m saying. react-native-reanimated is enabling react-native’s layout animation which I believe should not happen, hence, I created this issue.

Screen Shot 2022-10-06 at 9 47 29 AM

If you put a breakpoint inside react-native’s code to enable react-native’s implementation of layout animations, you can clearly see that it is being enabled by react-native-reanimated. It should not.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Auto animate layout updates - Android Developers
Android offers pre-loaded animation that the system runs each time you make a change to the layout. All you need to do is...
Read more >
The little secret of android:animateLayoutChanges
Recently, I have discovered a new one regarding android:animateLayoutChanges . For those unfamiliar with this XML attribute, it's a “automagical” way to animate...
Read more >
Switch - how to enable default animation in Android
Switch - how to enable default animation in Android ... The property android:animateLayoutChanges="true" does not have any effect. Tried on ...
Read more >
Animations | CodePath Android Cliffnotes
Layout Animations - This allows us to enable animations on any layout container or other ViewGroup such as LinearLayout, RelativeLayout, or ListView.
Read more >
core/java/android/animation/LayoutTransition.java
This class enables automatic animations on layout changes in ViewGroup objects. To enable ... This transition type is not enabled by default; it...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found