Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android keyboard slide animation

I have little (read: no) experience with animations in Android, but wanted to implement an animation for when the keyboard appears. Effectively, it would appear that the entire activity was sliding upwards (like the keyboard was below the activity and pushed it upwards), as opposed to only moving up so far as the selected EditText.

Does anyone know how to do this?

like image 490
Aneesh Ashutosh Avatar asked Jan 13 '23 14:01

Aneesh Ashutosh


2 Answers

In the latest version of Android OS (Android version 11), they 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.

WindowInsetsAnimation.Callback

For frame-perfect transitions, a new insets animation listener notifies apps of per-frame changes to insets while the system bars or the IME animate.

enter image description here

WindowInsetsAnimationController

Apps can take control of the IME and system bar transitions through the WindowInsetsAnimationController API.

enter image description here

like image 163
Darish Avatar answered Jan 28 '23 02:01

Darish


An app receives no notification of when a keyboard appears, and the android framework itself is responsible for either sliding the app or laying it out again. So customization isn't really possible. Which is probably a good thing- a keyboard is a separate app, and having written one I wouldn't want to even try to write the keyboard half of such an animation, we'd never get it to look right with all the various ways the app could do it.

The closest you'll get is to specify the fields to pan rather than resize when the keyboard is opened.

like image 27
Gabe Sechan Avatar answered Jan 28 '23 03:01

Gabe Sechan