From 52bb7e293d59266ef54f1bcb493265fa9a4f6f3e Mon Sep 17 00:00:00 2001 From: Ooi Keng Siang Date: Mon, 6 Mar 2023 17:30:00 +0800 Subject: [PATCH 1/3] Fix Android ListView header / footer gone (#12312) Fix incorrect layout value cause header / footer in ListView on Android gone missing / disappear when scrolling. --- .../Handlers/ListView/Android/ListViewRenderer.cs | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/Controls/src/Core/Compatibility/Handlers/ListView/Android/ListViewRenderer.cs b/src/Controls/src/Core/Compatibility/Handlers/ListView/Android/ListViewRenderer.cs index c2c4e30b8954..d9f20b2fd4a2 100644 --- a/src/Controls/src/Core/Compatibility/Handlers/ListView/Android/ListViewRenderer.cs +++ b/src/Controls/src/Core/Compatibility/Handlers/ListView/Android/ListViewRenderer.cs @@ -576,12 +576,9 @@ public IPlatformViewHandler Child protected override void OnLayout(bool changed, int l, int t, int r, int b) { - if (_child?.PlatformView == null) - { - return; - } - - _child.PlatformView.Layout(l, t, r, b); + // should not update platform view layout here + // because the top and bottom value from parameters are relative to current scroll position when it is call + // this mean top value might be nagative if header are off screen when user scroll back up } protected override void OnMeasure(int widthMeasureSpec, int heightMeasureSpec) @@ -592,6 +589,7 @@ protected override void OnMeasure(int widthMeasureSpec, int heightMeasureSpec) return; } + _child.PlatformView.Layout(0, 0, widthMeasureSpec, heightMeasureSpec); _child.PlatformView.Measure(widthMeasureSpec, heightMeasureSpec); SetMeasuredDimension(_child.PlatformView.MeasuredWidth, _child.PlatformView.MeasuredHeight); } From 584f8afd05b3c238536fec2dc168b2a7a32c2d89 Mon Sep 17 00:00:00 2001 From: Ooi Keng Siang Date: Tue, 14 Mar 2023 10:09:18 +0800 Subject: [PATCH 2/3] Fix OnLayout calculation after review Fix OnLayout calculation that caused header / footer gone missing. --- .../Handlers/ListView/Android/ListViewRenderer.cs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/Controls/src/Core/Compatibility/Handlers/ListView/Android/ListViewRenderer.cs b/src/Controls/src/Core/Compatibility/Handlers/ListView/Android/ListViewRenderer.cs index d9f20b2fd4a2..151222902670 100644 --- a/src/Controls/src/Core/Compatibility/Handlers/ListView/Android/ListViewRenderer.cs +++ b/src/Controls/src/Core/Compatibility/Handlers/ListView/Android/ListViewRenderer.cs @@ -576,9 +576,7 @@ public IPlatformViewHandler Child protected override void OnLayout(bool changed, int l, int t, int r, int b) { - // should not update platform view layout here - // because the top and bottom value from parameters are relative to current scroll position when it is call - // this mean top value might be nagative if header are off screen when user scroll back up + _child.PlatformView.Layout(0, 0, r - l, b - t); } protected override void OnMeasure(int widthMeasureSpec, int heightMeasureSpec) @@ -589,7 +587,6 @@ protected override void OnMeasure(int widthMeasureSpec, int heightMeasureSpec) return; } - _child.PlatformView.Layout(0, 0, widthMeasureSpec, heightMeasureSpec); _child.PlatformView.Measure(widthMeasureSpec, heightMeasureSpec); SetMeasuredDimension(_child.PlatformView.MeasuredWidth, _child.PlatformView.MeasuredHeight); } From 2722c9b3d98ebafceb8a0c041c280ed68d67293b Mon Sep 17 00:00:00 2001 From: Ooi Keng Siang Date: Wed, 15 Mar 2023 18:44:22 +0800 Subject: [PATCH 3/3] Add back removed null check Add back removed null check --- .../Handlers/ListView/Android/ListViewRenderer.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/Controls/src/Core/Compatibility/Handlers/ListView/Android/ListViewRenderer.cs b/src/Controls/src/Core/Compatibility/Handlers/ListView/Android/ListViewRenderer.cs index 151222902670..9dddc9b2a0db 100644 --- a/src/Controls/src/Core/Compatibility/Handlers/ListView/Android/ListViewRenderer.cs +++ b/src/Controls/src/Core/Compatibility/Handlers/ListView/Android/ListViewRenderer.cs @@ -576,6 +576,11 @@ public IPlatformViewHandler Child protected override void OnLayout(bool changed, int l, int t, int r, int b) { + if (_child?.PlatformView == null) + { + return; + } + _child.PlatformView.Layout(0, 0, r - l, b - t); }