question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Android] Window currently doesn't apply AdjustPan so the view doesn't pan up (scroll) when the keyboard opens

See original GitHub issue

Description

Original issue here

In XF Window.SetSoftInputMode(Android.Views.SoftInput.AdjustPan); would get called after the OnCreate call whereas in MAUI it’s called before OnCreate. It seems like this causes the property to have no effect

If you call this method after OnCreate than everything starts to work like XF.

Reproduction

If you take the XAML below and test a few different permutations, you’ll notice that the behavior isn’t currently consistent when you open a keyboard

  • Shell: Nothing happens
  • Shell/ScrollView: entry scrolls into view but ScrollView doesn’t reset
  • NavigationPage/ScrollView: entry scrolls into view but ScrollView doesn’t reset

If you test this scenario on XF all permutations work the same

  • the window pans up (scrolls up) when you open the keyboard
  • you close the keyboard and it pans back down
<StackLayout Padding="10">
            <Entry Text="Top"></Entry>
            <Entry></Entry>
            <Entry></Entry>
            <Entry></Entry>
            <Entry></Entry>
            <Entry></Entry>
            <Entry></Entry>
            <Entry></Entry>
            <Entry></Entry>
            <Entry></Entry>
            <Entry></Entry>
            <Entry Text="Middle"></Entry>
            <Entry></Entry>
            <Entry></Entry>
            <Entry></Entry>
            <Entry></Entry>
            <Entry></Entry>
            <Entry></Entry>
            <Entry></Entry>
            <Entry></Entry>
            <Entry></Entry>
            <Entry></Entry>
            <Entry Text="Bottom"></Entry>
        </StackLayout>

Workaround

Install the nuget here

or

Copy the handler and associated code from here into your code

Issue Analytics

  • State:closed
  • Created 10 months ago
  • Reactions:13
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
cerkzilcommented, Dec 3, 2022

AdjustPan doesn’t solve the problem completely, if the input doesn’t need to be panned to input text it works, but if it pans it still causes the same issue image

2reactions
Syed-RIcommented, Nov 10, 2022

@PureWeen thanks a lot !!! Really appreciate your hard work.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Android ScrollView doesn't scroll when the keyboard is up
Where adjustPan does not resize the window, it pans the view so that whatever has focus is never obscured by the soft keyboard....
Read more >
Android how to adjust for soft keyboard | by Yat Man, Wong
adjustPan shift the whole page up to make room for the keyboard. adjustResize resize the page, shrink whatever it can to display in...
Read more >
Handle input method visibility
When input focus moves in or out of an editable text field, Android shows or hides the input —such as the on-screen keyboard—as...
Read more >
Issue with adjustPan and adjustResize how to put ... - YouTube
Android Tutorial - Issue with adjustPan and adjustResize how to put elements above the softkeyboard. 12K views · 3 years ago ...more ...
Read more >
Soft keyboard input mode on Android - .NET MAUI
The Pan value uses the AdjustPan adjustment option, which doesn't resize the window when an input control has focus. Instead, the contents of ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found