点击editText时键盘显示和登录按钮隐藏如何调整键盘上方的自动按钮

问题描述 投票:0回答:1

已经在清单中使用 androidenter image description here:windowSoftInputMode="adjustResize" 请提出解决方案? 尝试使用 NestedScrollView 但不起作用,它可以工作,但是当我通过手指滚动屏幕时,按钮可以显示。请提供一些解决问题的建议

android xml android-studio android-layout
1个回答
0
投票

隐藏键盘

   val insets = ViewCompat.getRootWindowInsets(view)  // view can be edittext or root view

        insets?.let {
            val insetsController = WindowCompat.getInsetsController(window,view)

            // Show Keyboard if not visible
            if (!it.isVisible(WindowInsetsCompat.Type.ime())){
                insetsController.show(WindowInsetsCompat.Type.ime())
            }
            
            // Hide Keyboard
            insetsController.hide(WindowInsetsCompat.Type.ime())

        }
© www.soinside.com 2019 - 2024. All rights reserved.