Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Replacement for WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE in Android 11

Does anyone know the replacement for the adjust resize flag in Android 11? My layout has the EditText and it's getting hidden after the keyboard popup as I can't use the below the flag

getActivity().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);

Thanks

like image 373
ketan muttha Avatar asked May 03 '26 08:05

ketan muttha


1 Answers

Can you please try the following? I think you should add padding at the bottom of your view. The size of the padding should be the height of the keyboard.

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
    getActivity().getWindow().setDecorFitsSystemWindows(false);

    getActivity().getWindow().getDecorView().setOnApplyWindowInsetsListener((v, insets) -> {
        int height = insets.getInsets(WindowInsets.Type.ime()).bottom;
        v.setPadding(0, 0, 0, height);
        return insets;
    });
}
like image 87
Md Solaiman Hosen Avatar answered May 07 '26 00:05

Md Solaiman Hosen