简体   繁体   中英

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?

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.

在此处输入图片说明

WindowInsetsAnimationController

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

在此处输入图片说明

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM