简体   繁体   English

告诉带有“adjustNothing”的键盘何时打开

[英]Tell when keyboard with "adjustNothing" opens

In my app I am using the adjustNothing flag to my keyboard.在我的应用程序中,我在键盘上使用了 adjustNothing 标志。 That it a requirement.. Please don't advice me to change it to "resize or pan" :)这是一个要求..请不要建议我将其更改为“调整大小或平移”:)

My question is if there is any way of knowing when the keyboard opens and closes in this state?我的问题是有没有办法知道键盘在这种状态下何时打开和关闭?

I tried "onGlobalLayout" and "onConfigurationChanged" without any luck.我尝试了“onGlobalLayout”和“onConfigurationChanged”但没有任何运气。 Since the keyboard is not "doing" anything to the app I don't seam to find any way the catch this event.. Please help!由于键盘没有对应用程序“执行”任何操作,因此我无法找到任何方法来捕获此事件.. 请帮忙!

Yes!是的! It's not nice as iOS where you get the height and animation but at least you know that it opens:它不像 iOS 那样可以获取高度和动画,但至少你知道它打开了:

ViewCompat.setOnApplyWindowInsetsListener(findViewById(android.R.id.content), new OnApplyWindowInsetsListener() {
                @Override
                public WindowInsetsCompat onApplyWindowInsets(View v, WindowInsetsCompat insets) {
}

This tells you whenever any kind of change happens.这会告诉您何时发生任何类型的更改。 It's easy knowing that the keyboard is the reason for that change and act accordingly.很容易知道键盘是导致这种变化的原因并采取相应的行动。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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