我正在尝试使用Xamarin Android创建全屏模式(如视频播放器)应用程序。不幸的是,我遇到了一个问题,关于在状态栏位置显示的空白区域。
我附上了有关我的问题的截图。
在MainActivity上听我的代码:
Window.SetFlags(WindowManagerFlags.Fullscreen, WindowManagerFlags.Fullscreen);
Window.DecorView.SystemUiVisibility = (StatusBarVisibility)(
SystemUiFlags.LayoutStable |
SystemUiFlags.LayoutHideNavigation |
SystemUiFlags.LayoutFullscreen |
SystemUiFlags.HideNavigation |
SystemUiFlags.ImmersiveSticky |
SystemUiFlags.Fullscreen);
这是我的style.xml
:
<style name="MyTheme" parent="MyTheme.Base">
</style>
<style name="MyTheme.Base" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="windowNoTitle">true</item>
<item name="android:windowFullscreen">true</item>
<item name="android:windowBackground">@drawable/splashscreen</item>
</style>
答案 0 :(得分:0)
I'm struggling for days... put this in OnCreate method (mainactivity.cs)
public class MainActivity : FormsAppCompatActivity
{
protected override void OnCreate(Bundle bundle)
{
TabLayoutResource = Resource.Layout.Tabbar;
ToolbarResource = Resource.Layout.Toolbar;
this.Window.AddFlags(WindowManagerFlags.Fullscreen | WindowManagerFlags.TurnScreenOn);
if (Build.VERSION.SdkInt >= BuildVersionCodes.Lollipop)
{
var stBarHeight = typeof(FormsAppCompatActivity).GetField("statusBarHeight", BindingFlags.Instance | BindingFlags.NonPublic) ?? typeof(FormsAppCompatActivity).GetField("_statusBarHeight", BindingFlags.Instance | BindingFlags.NonPublic);
stBarHeight?.SetValue(this, 0);
}
base.OnCreate(bundle);
Forms.Init(this, bundle);
LoadApplication(new App());
}
public override void OnRequestPermissionsResult(int requestCode, string[] permissions, Permission[] grantResults)
{
PermissionsImplementation.Current.OnRequestPermissionsResult(requestCode, permissions, grantResults);
}
}