MAUI: The UI is shrinking after setting the SoftInputMode to AdjustResize

Sreejith Sreenivasan 1,001 Reputation points
2024-01-04T15:12:25.64+00:00

I have a UI and when keyboard appears the header part is not visible like below screenshot.

1

So I set the SoftInputModeto AdjustResize for that page and when leave that page I set it back to AdjustPan.

protected override void OnAppearing()
{
	base.OnAppearing();
#if ANDROID
			        Platform.CurrentActivity?.Window?.SetSoftInputMode(Android.Views.SoftInput.AdjustResize);
#endif
}

protected override void OnDisappearing()
{
    base.OnDisappearing();
#if ANDROID
        Platform.CurrentActivity?.Window?.SetSoftInputMode(Android.Views.SoftInput.AdjustPan);
#endif
}

The SoftInputMode was set successfully, but when I came back to the home page, the UI is compressed(Shrink) like below screenshot. (right side actual UI, left side after setting SoftInputMode to resize image)

2

If I go to keypad or any other page and come back, the home page UI is showing as normal without shrinking.

In addition I added pan as the SoftInputMode in MainActivity.

protected override void OnCreate(Bundle savedInstanceState)
{
    base.OnCreate(savedInstanceState);
    App.Current.On<Microsoft.Maui.Controls.PlatformConfiguration.Android>().UseWindowSoftInputModeAdjust(WindowSoftInputModeAdjust.Pan);
}
Developer technologies | .NET | .NET MAUI
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.