


We can do that by calling the controlWindowInsetsAnimation method of the WindowInsetsController class. The first step is to request control over the IME. In this example and in order to replicate the animation shown below, we are going to have a ScrollView with some items hidden so it can scroll up. For example, an app can take control of the IME in response to overscrolling its UI. For example, we can request the system window insets like so:Īpps can now control the soft keyboard (IME) and system bar transitions by using a new WindowInsetsAnimationController class. This method accepts as a parameter the type of insets that we’re interested in, which are listed on the WindowInsets.Typeclass. In Android 11 these methods are deprecated and are instead replaced by a single getInsetsmethod on the WindowInsetsclass. Previously, when working with WindowInsets (like when implementing edge-to-edge) you had to call several methods on the WindowInsetsclass like getSystemWindowInsets or getSystemGestureInsets. Android 11 Developer Preview 2 introduced a long-awaited feature: the ability to synchronize the app’s content with the IME (soft keyboard) and system bars as they animate on and offscreen, instead of having the view simply jump on top of the keyboard when it opens.Īfter reading about this feature, I went on to try to replicate the animations shown on the Android Developers blog announcement (shown above) and in this post I’ll show you the necessary steps.īut before diving into these new features, we are going to discuss some changes introduced to WindowInsets on Android 11, which will be useful later on.
