Use this to obtain the margin bottom to RootView and the navigation doesn't overlap
public static int getSoftButtonsBarSizePort(Activity activity) {
// getRealMetrics is only available with API 17 and +
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
DisplayMetrics metrics = new DisplayMetrics();
activity.getWindowManager().getDefaultDisplay().getMetrics(metrics);
int usableHeight = metrics.heightPixels;
activity.getWindowManager().getDefaultDisplay().getRealMetrics(metrics);
int realHeight = metrics.heightPixels;
if (realHeight > usableHeight)
return realHeight - usableHeight;
else
return 0;
}
return 0;
}
And the OnCreate Method
var rootView = ((ViewGroup)this.FindViewById(Android.Resource.Id.Content)).GetChildAt(0);
//var rootView = this.Window.DecorView.RootView;
ViewGroup.MarginLayoutParams layoutParams;
if (rootView.LayoutParameters != null)
{
layoutParams = (ViewGroup.MarginLayoutParams)rootView.LayoutParameters;
}
else
{
layoutParams = new ViewGroup.MarginLayoutParams(rootView.Width, rootView.Height);
}
var margin = GetSoftButtonsBarSizePort(this);
layoutParams.SetMargins(rootView.Left, rootView.Top, rootView.Right, margin);
rootView.LayoutParameters = layoutParams;
rootView.RequestLayout();