In my Xamarin Forms Android application I'm trying to disable this Predictive back gesture while we swipe left or right from edge of the screen, the app will go back or forward and it messes with the swipe in my tabbed page. sometimes when we swipe to switch tabs it accidentally minimises the application. So I tried the below solution in my Custom ContentPage Renderer, but still it didnt work. Can anyone help me with that ?
I tried all the possibilities below and still issues exists.
[assembly: ExportRenderer(typeof(ContentPage), typeof(CustomPageRenderer))]
namespace ServiceMattersApp.Droid.Renderers
{
public class CustomPageRenderer : PageRenderer
{
public CustomPageRenderer(Context context) : base(context)
{
}
protected override void OnLayout(bool changed, int left, int top, int right, int bottom)
{
if (changed && Element != null)
{
Android.Graphics.Rect exclusionRect = new Android.Graphics.Rect(0, 0,0,0);
var rects = new Android.Graphics.Rect[] { exclusionRect };
SystemGestureExclusionRects = rects;
}
base.OnLayout(changed, left, top, right, bottom);
}
}
}
Here are the other things I tried .
var rootView = ((Activity)Context).FindViewById(Android.Resource.Id.Content);
if (rootView != null)
{
ViewCompat.SetSystemGestureExclusionRects(rootView, rects);
rootView.RootView.SystemGestureExclusionRects = rects;
}
I even tried these codes in the OnElementChanged method and still the swipe exists. Expected result - The predictive swipe system gesture should be disabled for left and right side of the screen. Can anyone help me with this please