how to use the windowinsetsanimation in Android 11 (Android R or Android API level 30)

2.3k Views Asked by At

The new Android version (Android 11) added new set of APIs let you synchronize your app’s content with the IME (input method editor, aka soft keyboard) and system bars as they animate on and offscreen, making it much easier to create natural, intuitive and jank-free IME transitions.

So, how to apply the windowinsetsanimation in android r (Android 11)?

1

There are 1 best solutions below

0
On BEST ANSWER

enter image description here

Here is a sample gif of the desired animation effects. There are two modes, WindowInsetsAnimation.Callback and WindowInsetsAnimationController.

In your build.gradle file, set your minSdk version to android R

 minSdkVersion "R"

Define your fragment with RecyclerView and EditText

  1. Define your animation listener and controller implementations.
  2. Define your fragment with RecyclerView and EditText Box and attach the listener to the edit text and controller with the recycler view for the desired animation effect.

A complete working sample can be found here.