Search code examples
androidandroid-jetpack-compose

Jetpack Compose: Keyboard covers the TextField in dialog


In short: using Jetpack Compose, the keyboard overlaps the TextField when it is opened in an AlertDialog. I've tried everything I've found:

  • added android:windowSoftInputMode="adjustResize" to the Activity in AndroidManifest.xml

  • set decorFitsSystemWindows = false on the DialogProperties

  • called WindowCompat.setDecorFitsSystemWindows(window, false) for the dialog's window

  • called WindowCompat.setDecorFitsSystemWindows(window, false) in the Activity's onCreate() method

  • used this ImeState approach from: https://www.youtube.com/watch?v=kgoJfl_Oc5E

  • used the BringIntoViewRequester:

    modifier
        .onFocusEvent {
            if (it.isFocused) {
                coroutineScope.launch {
                    delay(200)
                    bringIntoViewRequester.bringIntoView()
                }
            }
        }
        .bringIntoViewRequester(bringIntoViewRequester)
    

I've created a GitHub repository with a demo project: Demo project - TextField covered by keyboard

Can you help me to understand what am I missing? I'm completely out of ideas.

Screenshots:
Dialog with TextField TextField covered by the keyboard

UPDATE - SOLVED

Based on the answer of @Shubham Thorat, I used adjustPan in the following way:

  • AndroidManifest.xml: android:windowSoftInputMode="adjustPan"
  • in the LaunchedEffect(imeState.value):
    WindowCompat.setDecorFitsSystemWindows(wnd, false)
    wnd.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN)
    

Solution

  • Can you try this one:

    android:windowSoftInputMode="adjustPan"