在android项目里,这样设置

using System;

using Android.App;
using Android.Content.PM;
using Android.Runtime;
using Android.Views;
using Android.Widget;
using Android.OS; namespace Doubi.Droid
{
[Activity(Label = "Doubi", Icon = "@mipmap/icon", Theme = "@style/MainTheme", MainLauncher = true, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation)]
public class MainActivity : global::Xamarin.Forms.Platform.Android.FormsAppCompatActivity
{
protected override void OnCreate(Bundle bundle)
{
TabLayoutResource = Resource.Layout.Tabbar;
ToolbarResource = Resource.Layout.Toolbar; var uiOpts = SystemUiFlags.LayoutStable | SystemUiFlags.LayoutFullscreen;
//LayoutStable表示布局稳定,不随其他变动而变动
//LayoutFullscreen表示把布局拓宽到全屏幕 Window.DecorView.SystemUiVisibility = (StatusBarVisibility)uiOpts; //把标题栏设置为透明色
Window.SetStatusBarColor(Android.Graphics.Color.Argb(,,,)); base.OnCreate(bundle); Doubi.KLineView.Density = Resources.DisplayMetrics.Density; global::Xamarin.Forms.Forms.Init(this, bundle);
LoadApplication(new App());
}
}
}

更多UIFlag的说明:

SYSTEM_UI_FLAG_LOW_PROFILE弱化状态栏和导航栏的图标
SYSTEM_UI_FLAG_HIDE_NAVIGATION隐藏导航栏,用户点击屏幕会显示导航栏
SYSTEM_UI_FLAG_FULLSCREEN隐藏状态栏
SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION拓展布局到导航栏后面
SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN拓展布局到状态栏后面
SYSTEM_UI_FLAG_LAYOUT_STABLE稳定的布局,不会随系统栏的隐藏、显示而变化
SYSTEM_UI_FLAG_IMMERSIVE沉浸模式,用户可以交互的界面
SYSTEM_UI_FLAG_IMMERSIVE_STICKY沉浸模式,用户可以交互的界面。同时,用户上下拉系统栏时,会自动隐藏系统栏
 
05-11 21:43