UPDATEIf I use windowSoftInputMode=adjustPan => not all EditText is push up to above keyboardIf I use windowSoftInputMode=adjustResize => Button, TextView and all EditText is push up to above keyboard推荐答案使用 WindowInsetsCompat 的新功能可以帮助轻松检测键盘可见性(我在此处遵循答案 https://stackoverflow.com/a/63517673/5381331).不再像以前那样使用 windowSoftInputMode=adjustPan 来解决不太复杂的问题,现在我可以通过将 windowSoftInputMode=adjustResize 与 WindowInsetsCompatWith the new feature of WindowInsetsCompat which help detecting keyboard visibility easily (I follow answer here https://stackoverflow.com/a/63517673/5381331).Instead of using windowSoftInputMode=adjustPan for less complex like before, now I can solve this problem by combine windowSoftInputMode=adjustResize with WindowInsetsCompatViewCompat.setOnApplyWindowInsetsListener(root) { v, insets -> val isKeyboardVisible = insets.isVisible(WindowInsetsCompat.Type.ime()) if (isKeyboardVisible) { // Hide some view when keyboard visible } else { // Show it again here }}AndroidManifestAndroidManifest<activity android:name=".activity_name" android:windowSoftInputMode="adjustResize"> // all content will push to above keyboard then we able to scroll to see whole content</activity> 这篇关于显示键盘时向上推除某些视图外的内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
07-24 15:55