Skip to content
This repository was archived by the owner on May 1, 2024. It is now read-only.
This repository was archived by the owner on May 1, 2024. It is now read-only.

[Bug] In some cases on Forms 5.0-pre3 the screen isn't being refreshed properly on Android #12567

@calvinfa

Description

@calvinfa

Description

I have encountered a few cases where going back (PopAsync) or changing the current page doesn't re-render the page properly on Android. I have isolated a small test sample to demonstrate this issue.

Steps to Reproduce

  1. Create a new XAML file with the following contents:
<?xml version="1.0" encoding="UTF-8"?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms" 
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             x:Class="Xaminals.Views.BearsPage"
             Title="Test">
    <ScrollView>
        <StackLayout>
            <!-- Empty layout for testing, normally filled -->
            <StackLayout Padding="20" HorizontalOptions="FillAndExpand" HeightRequest="1000" />

            <!-- Layout with IsVisible-->
            <StackLayout Padding="20">
                <Button Text="Click me!" Command="{Binding ButtonCommand}" />

                <StackLayout IsVisible="{Binding IsExtraVisible}">
                     <Label Text="Label9"
                            FontSize="18"
                            HorizontalOptions="FillAndExpand" />

                    <Entry Text="TestText"
                           Placeholder="Placeholder" />
                </StackLayout>
            </StackLayout>

            <!-- Bottom Layout -->
            <StackLayout Padding="20" HorizontalOptions="FillAndExpand" MinimumHeightRequest="32">
                <Button Text="Save!"
                        Padding="20,0"
                        HorizontalOptions="FillAndExpand" />
            </StackLayout>
        </StackLayout>
    </ScrollView>
</ContentPage>
  1. Enter the following code in the code file of the xaml file:
using System.ComponentModel;
using System.Runtime.CompilerServices;
using Xamarin.Forms;

namespace Xaminals.Views
{
    public partial class BearsPage : ContentPage, INotifyPropertyChanged
    {
        public BearsPage()
        {
            InitializeComponent();

            BindingContext = this;
        }

        public Command ButtonCommand => new Command(() =>
        {
            IsExtraVisible = true;
            RaisePropertyChanged(nameof(IsExtraVisible));
        });

        public bool IsExtraVisible { get; set; } = false;

        public event PropertyChangedEventHandler PropertyChanged;

        public void RaisePropertyChanged([CallerMemberName] string propertyName = "")
        {
            PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
        }
    }
}
  1. Run the project on Android and press the Click me! button.

Expected Behavior

The StackLayout that has IsVisible should become visible and the view should properly expand the view to accommodate the newly displayed elements with the existing elements

Actual Behavior

The StackLayout becomes visible but pushes the Save! button out of frame. This can be resolved by rotating the tablet for a bit so that we force a redraw

Basic Information

  • Version with issue: 5.0.0-pre3
  • Last known good version: 5.0.0-pre1
  • IDE: Visual Studio for Mac
  • Platform Target Frameworks:
    • iOS: 8.0
    • Android: 10.0
  • Nuget Packages: Xamarin.Forms (5.0.0-1558-pre3)
  • Affected Devices: Android Simulator running Android 8.1.0, Galaxy Tab S2 running Android 7.0

Screenshots

android_screen

Reproduction Link

Archive.zip

Workaround

No workaround found yet

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions