android.netmaui

Entry on .NET Maui 8 Goes to Top Left of Screen in Landscape Mode


My application has been developed using .NET Maui 8.0 primarily for use on Android devices. What I have found is that when running the application on Android in Landscape mode and the focus is on an Entry control, the screen goes blank showing just a simple Done button. It then requires the text to be entered in the top right hand corner of the screen. (The screen is not scrolling up, it just shows nothing).

After the text has been entered and the Done button clicked, the screen is displayed as it should be with the text displayed in the entry box in the correct place.

Is there any way the text can be entered in-place, without hiding the rest of the controls? This happens only in landscape mode, when in portrait mode the entry occurs in-place as it should do.


    <?xml version="1.0" encoding="utf-8" ?>
    <ContentPage
        x:Class="WmsClient.View.SettingsPasswordPage"
        xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
        xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
        Title="SettingsPasswordPage">
        <Grid
            BackgroundColor="White"
            ColumnDefinitions="*"
            RowDefinitions="50,*,80,80">
    
            <VerticalStackLayout Grid.Row="1">
    
                <Label
                    Margin="0,20,0,0"
                    FontSize="26"
                    HorizontalOptions="Center"
                    Text="Password"
                    TextColor="Black" />
    
                <Frame
                    Margin="0,20,0,0"
                    Padding="0,0,0,0"
                    BackgroundColor="White"
                    BorderColor="Gray"
                    CornerRadius="4"
                    WidthRequest="300">
                    <Entry
                        Grid.Row="1"
                        FontSize="20"
                        HorizontalOptions="Fill"
                        IsEnabled="True"
                        IsPassword="False"
                        Text="{Binding EntryText}"
                        TextColor="Black" />
                </Frame>
            </VerticalStackLayout>
    
        </Grid>
    </ContentPage>

This page is displayed when the entry control is tapped


Solution

  • The problem can be resolved by changing the Android IME options for the entry control. This can be done by adding the following lines to the Content Page.

    xmlns:android="clr-namespace:Microsoft.Maui.Controls.PlatformConfiguration.AndroidSpecific;assembly=Microsoft.Maui.Controls"
    
    <Entry android:Entry.ImeOptions="NoExtractUi"/>
    

    The XML for the page in full is shown here: -

    <?xml version="1.0" encoding="utf-8" ?>
    <ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
                 xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
                 xmlns:android="clr-namespace:Microsoft.Maui.Controls.PlatformConfiguration.AndroidSpecific;assembly=Microsoft.Maui.Controls"
                 x:Class="WmsClient.View.TestPage"
                 Title="TestPage">
        <Grid
                BackgroundColor="White"
                ColumnDefinitions="*"
                RowDefinitions="50,*,80,80">
    
            <VerticalStackLayout Grid.Row="1">
    
                <Label Margin="0,20,0,0"
                        FontSize="26"
                        HorizontalOptions="Center"
                        Text="Password"
                        TextColor="Black" />
                <Frame Margin="0,20,0,0"
                       Padding="0,0,0,0"
                       BackgroundColor="White"
                       BorderColor="Gray"
                       CornerRadius="4"
                       WidthRequest="300">
                    <Entry
                        Grid.Row="1"
                        android:Entry.ImeOptions="NoExtractUi"
                        FontSize="20"
                        HorizontalOptions="Fill"
                        IsEnabled="True"
                        IsPassword="False"
                        Text="{Binding EntryText}"
                        TextColor="Black" />
                </Frame>
            </VerticalStackLayout>
    
        </Grid>
    </ContentPage>