Open czwinzscher opened 3 years ago
I'm also having this issue with Android 11. Any updates or workaround?
I've tried XF 4.8 and the latest 5.0, both able to replicate this issue on Android 11. However, both works fine on Android 10 and earlier.
After looking at a similar issue and debugging with the sample demo to PopupPageRenderer.cs
, it seems like with Android 11, the OnLayout()
wasn't triggered the same as Android 10; and decoreView?.GetWindowVisibleDisplayFrame(visibleRect);
captured before the keyboard is displayed.
My workaround is to listen to GlobalLayout
event and do a RequestLayout()
whenever the keyboard is shown/hidden. The steps are:
using System;
using Android.App;
using Android.Content;
using Android.Runtime;
using Android.Views;
using MyTest.Droid.Renderers;
using MyTest.Xamarin.Controls;
using Xamarin.Forms;
[assembly: ExportRenderer(typeof(PopUpBase), typeof(PopUpBaseRenderer))] namespace MyTest.Droid.Renderers { [Preserve(AllMembers = true)] public class PopUpBaseRenderer : Rg.Plugins.Popup.Droid.Renderers.PopupPageRenderer { private Android.Graphics.Rect LastVisibleRect;
public PopUpBaseRenderer(Context context) : base(context) { }
protected override void OnAttachedToWindow()
{
ViewTreeObserver.GlobalLayout += ViewTreeObserver_GlobalLayout;
base.OnAttachedToWindow();
}
protected override void OnDetachedFromWindow()
{
ViewTreeObserver.GlobalLayout -= ViewTreeObserver_GlobalLayout;
base.OnDetachedFromWindow();
}
private void ViewTreeObserver_GlobalLayout(object sender, EventArgs e)
{
Console.WriteLine($"global layout");
try
{
var activity = (Activity?)Context;
var decoreView = activity?.Window?.DecorView;
var visibleRect = new Android.Graphics.Rect();
decoreView?.GetWindowVisibleDisplayFrame(visibleRect);
Console.WriteLine($"visible Rect: {visibleRect.FlattenToString()}");
if (LastVisibleRect?.FlattenToString() != visibleRect.FlattenToString())
{
Console.WriteLine($"global layout RequestLayout");
LastVisibleRect = visibleRect;
this.RequestLayout();
}
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
}
}
}
2. And PopUpBase is just the PopupPage:
```c#
public class PopUpBase : PopupPage {}
Briefly tested and seems to work
Hey @simon10says great work here.
I will try and give this a squiz as soon as possible, but in a more integrated way into the PopupRenderer.
Any update on the issue?
@simon10says Thanks It's working fine now. I also facing the problem keyboard overlap on the Rg.Popup page but with your code it's working fine. Thanks again. Rg.Plugins.Popup (2.1.0) Xamarin.Forms (5.0.0.2337)
We're experiencing the same issue on Android 12 as well!
Hey @simon10says great work here.
I will try and give this a squiz as soon as possible, but in a more integrated way into the PopupRenderer.
Working for me too. Thanks for sharing the solution.
Thankyou, your solution saved me a big headache as I really didn't know what to do next. In my case the popup was not redrawing when the keyboard was hidden. You solution addressed that for me :)
š Bug Report
On Android 11, when opening a Popup with an Entry and then focusing the entry, the Popup doesn't get moved up when the keyboard appears. Only when you start typing something the Popup gets moved. When the keyboard gets dismissed the Popup also doesn't move back down. It's working as expected on Android 9 and 10.
Expected behavior
The Popup gets moved up when the keyboard appears so the Popup and the keyboard don't overlap. The Popup should move back down when the keyboard disappears.
Reproduction steps
Configuration
Version: 2.0.0.12
Platform: