androidkotlinkeyboardandroid-jetpack-composetextfield

Android Jetpack Compose keyboard not close


Compose keyboard not close when scrolling

everything is okey

I'm scrolling but keyboard not close

how can i solve this?

thank you in advance for the answers.


Solution

  • If want hide the keyboard on scroll, you need to hide the on the scroll action of your nestedScrollConnection

    val keyboardController = LocalSoftwareKeyboardController.current
    val nestedScrollConnection = remember {
    object : NestedScrollConnection {
        override fun onPreScroll(available: Offset, source:NestedScrollSource): Offset {
            val delta = available.y
            keyboardController?.hide()
            return Offset.Zero
          }
       }
    }  
    
    Box(Modifier.fillMaxSize().nestedScroll(nestedScrollConnection)) {
          LazyColumn(){
               // Here your list itens
          }
    }