SetSoftInputMode vs WindowSoftInputMode

Nathan Sokalski 4,111 Reputation points
2021-10-28T02:47:59.93+00:00

My app involves parts (in the same Activity) that have different needs for the WindowSoftInputMode. One area needs SoftInput.AdjustPan, and another needs SoftInput.AdjustNothing. In order to do this, I am using the following lines of code:

this.Window.SetSoftInputMode(SoftInput.AdjustPan);

this.Window.SetSoftInputMode(SoftInput.AdjustNothing);

The AdjustNothing seems to work (although I can't tell for sure, since there are a lot of options that would work in that scenario, but it does what I need it do). However, AdjustPan does not seem to work when setting it in code, and I have confirmed that the code is being called. If I set it in the Activity attribute, it works, but because I need to be able to change it from code. Is there something that is wrong with my code? Am I forgetting something?

Developer technologies | .NET | Xamarin
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Anonymous
    2021-10-29T02:27:04.81+00:00

    Hello,​

    Welcome to our Microsoft Q&A platform!

    The AdjustNothing seems to work (although I can't tell for sure, since there are a lot of options that would work in that scenario, but it does what I need it do). However, AdjustPan does not seem to work when setting it in code

    AdjustPan If the input box is higher than the height of the keyboard pop-up, it will not have any impact on the interface, and will not compress the background image, etc. If the input box is lower than the pop-up height of the keyboard, no matter whether there is a scroll control or not, no interface will be compressed, and the entire interface will be moved up. The keyboard does not automatically pop up .

    For testing a SoftInput.AdjustNothing and SoftInput.AdjustPan, I set the edittext in the bottom of the screen, you will find the AdjustPan works( titlebar will be moved outof screen).

    By the way, if SoftInput.AdjustNothing works, you will find the edittext be covered( If the input box is lower than the height of the keyboard pop-up)

    Best Regards,

    Leon Lu


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

Your answer

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