SoftInput.AdjustPan Not Working in Landscape

Nathan Sokalski 4,116 Reputation points
2022-03-26T21:41:11.057+00:00

I have created a default & landscape layout for my app, both of which contain an EditText. The EditText is exactly the same in both xml files. In the Activity attribute of my MainActivity class I include WindowSoftInputMode = SoftInput.AdjustPan, and I do not attempt to change this anywhere in my code. In portrait, everything works fine & as expected (the screen is shifted upwards to show the keyboard), but in landscape, the entire screen is hidden (both the EditText & other View(s)). The keyboard gets displayed, and allows the user to type, although they might barely know why they are typing, since even though they can see the text, they cannot see any other View(s) that describe the purpose of the EditText. I have tested this on the following:

Surface Duo
Samsung Galaxy S10e
Emulator in Visual Studio 2022

The problem does not occur with Surface Duo (even when I use single screen to have the keyboard displayed on the same screen), but it does occur on the S10e & emulator. Here are screenshots from the emulator in both portrait & landscape (the S10e looks almost the same):

187211-screenshot-1648329691.png

187166-screenshot-1648329708.png

Here is the xml for the EditText (this code is exactly the same for default & landscape):

<EditText android:id="@+id/txtCustomWin" android:layout_width="0dp" android:layout_height="wrap_content"  
	android:layout_weight="1" style="@style/BasicEditTextStyle" android:textColorHighlight="@color/RoyalBlue"  
	android:layout_gravity="center" android:gravity="right" android:paddingRight="4dp" android:textAlignment="gravity"  
	android:includeFontPadding="false" android:textSize="30dp" android:textStyle="bold" android:selectAllOnFocus="true"  
	android:inputType="number" android:numeric="integer" android:ellipsize="none" android:imeOptions="actionDone" tools:text="100000"/>  
Xamarin
Xamarin
A Microsoft open-source app platform for building Android and iOS apps with .NET and C#.
5,296 questions
0 comments No comments
{count} votes

Accepted answer
  1. Yonglun Liu (Shanghai Wicresoft Co,.Ltd.) 35,806 Reputation points Microsoft Vendor
    2022-03-28T01:53:14.047+00:00

    Hello,

    You need to add the following property in your EditText of the landscape.xml file:

    android:imeOptions="flagNoExtractUi|flagNoFullscreen"

    Then, you will find everything works fine in landscape mode.

    You can refer to ImeFlags Enum to get more details about ImeFlags.

    Best Regards,

    Alec Liu.


    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

0 additional answers

Sort by: Most helpful