[Xamarin.Forms]How to make App run in fullscreen in Android?
aluzi liu
486
Reputation points
I put this code on MainActivity's OnCreate method:
if (Build.VERSION.SdkInt >= BuildVersionCodes.Lollipop)
{
// Kill status bar underlay added by FormsAppCompatActivity
// Must be done before calling FormsAppCompatActivity.OnCreate()
var statusBarHeightInfo = typeof(FormsAppCompatActivity).GetField("statusBarHeight", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic);
if (statusBarHeightInfo == null)
{
statusBarHeightInfo = typeof(FormsAppCompatActivity).GetField("_statusBarHeight", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic);
}
statusBarHeightInfo?.SetValue(this, 0);
}
base.OnCreate(savedInstanceState);
this.Window.AddFlags(WindowManagerFlags.Fullscreen | WindowManagerFlags.TurnScreenOn);
And I get this:
The status bar is gone, but It still occupies this space, and the page content did not display at fullscreen.
What can I do?