Forum Xamarin.Forms
We are excited to announce that the Xamarin Forums are moving to the new Microsoft Q&A experience. Q&A is the home for technical questions and answers at across all products at Microsoft now including Xamarin!

We encourage you to head over to Microsoft Q&A for .NET for posting new questions and get involved today.

ScrollView scrolls on iOS but not Android

My XAML content is below. My issue is when I tap into an Entry field to enter some text, the onscreen keyboard appears but I'm not able to scroll the view on Android. The view does scroll on iOS. Is there something I'm doing wrong or is this a bug? I'm using Xamarin.Forms 4.2.0.848062

<?xml version="1.0" encoding="utf-8" ?>
<ContentPage
    xmlns="http://xamarin.com/schemas/2014/forms"
    xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
    xmlns:d="http://xamarin.com/schemas/2014/forms/design"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d">

    <ContentPage.Content>
        <ScrollView>
            <StackLayout>
                <Grid>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="250" />
                    </Grid.RowDefinitions>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="*" />
                    </Grid.ColumnDefinitions>
                    <Grid>
                        <Image
                            x:Name="imageToUpload"
                            Grid.Row="0"
                            Aspect="AspectFill"
                            HorizontalOptions="FillAndExpand"
                            VerticalOptions="FillAndExpand" />
                        <Image Grid.Row="0" IsVisible="{Binding HasImage, Converter={StaticResource InverseBoolConverter}}">
                            <Image.GestureRecognizers>
                                <TapGestureRecognizer NumberOfTapsRequired="1" Tapped="OnPhotoImageTap" />
                            </Image.GestureRecognizers>
                            <Image.Source>
                                <FontImageSource
                                    FontFamily="{DynamicResource MaterialFontFamily}"
                                    Glyph="{StaticResource ImagePlusIcon}"
                                    Size="200" />
                            </Image.Source>
                        </Image>
                    </Grid>
                </Grid>

                <Entry
                    x:Name="Description"
                    Margin="30,20,30,0"
                    FontFamily="{StaticResource RegularFont}"
                    IsVisible="{Binding HasImage}"
                    Placeholder="{Binding DescriptionEntryPlaceholder}"
                    Text="{Binding Upload.Comment}" />

                <Grid
                    Margin="25,0,30,0"
                    HorizontalOptions="FillAndExpand"
                    IsVisible="{Binding HasImage}"
                    VerticalOptions="Start">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="0.1*" />
                        <ColumnDefinition Width="*" />
                    </Grid.ColumnDefinitions>
                    <CheckBox
                        x:Name="EmailPhoto"
                        Grid.Row="0"
                        Grid.Column="0"
                        IsChecked="{Binding EmailPhoto}"
                        VerticalOptions="Center" />
                    <Label
                        Grid.Row="0"
                        Grid.Column="1"
                        FontFamily="{StaticResource RegularFont}"
                        FontSize="14"
                        Text="Email Photo"
                        VerticalOptions="Center" />
                </Grid>

                <Entry
                    x:Name="EmailAddressEntry"
                    Margin="30,0,30,20"
                    FontFamily="{StaticResource RegularFont}"
                    IsVisible="{Binding EmailPhoto}"
                    Keyboard="Email"
                    Placeholder="Email Address"
                    Text="{Binding Upload.EmailPhotoAddress}" />

                <Button
                    Grid.Row="4"
                    Grid.Column="1"
                    Clicked="OnSubmitClicked"
                    FontFamily="{StaticResource RegularFont}"
                    IsVisible="{Binding HasImage}"
                    Text="Submit Photo" />
            </StackLayout>
        </ScrollView>
    </ContentPage.Content>
</ContentPage>

Best Answer

  • JarvanJarvan Member, Xamarin Team Xamurai
    edited October 2019 Accepted Answer

    It's an issue on Android. To solve this, try to add UseWindowSoftInputModeAdjust method after LoadApplication().

    Check the code.

    protected override void OnCreate(Bundle savedInstanceState)
    {
        ...
        base.OnCreate(savedInstanceState);
    
        Xamarin.Essentials.Platform.Init(this, savedInstanceState);
        global::Xamarin.Forms.Forms.Init(this, savedInstanceState);
        LoadApplication(new App());
    
        Xamarin.Forms.Application.Current.On<Xamarin.Forms.PlatformConfiguration.Android>().UseWindowSoftInputModeAdjust(WindowSoftInputModeAdjust.Resize);
    }
    

Answers

  • JarvanJarvan Member, Xamarin Team Xamurai
    edited October 2019 Accepted Answer

    It's an issue on Android. To solve this, try to add UseWindowSoftInputModeAdjust method after LoadApplication().

    Check the code.

    protected override void OnCreate(Bundle savedInstanceState)
    {
        ...
        base.OnCreate(savedInstanceState);
    
        Xamarin.Essentials.Platform.Init(this, savedInstanceState);
        global::Xamarin.Forms.Forms.Init(this, savedInstanceState);
        LoadApplication(new App());
    
        Xamarin.Forms.Application.Current.On<Xamarin.Forms.PlatformConfiguration.Android>().UseWindowSoftInputModeAdjust(WindowSoftInputModeAdjust.Resize);
    }
    
Sign In or Register to comment.